static int dsi_event_thread(void *data) { struct mdss_dsi_event *ev; struct dsi_event_q *evq; struct mdss_dsi_ctrl_pdata *ctrl; unsigned long flag; struct sched_param param; u32 todo = 0; int ret; param.sched_priority = 16; ret = sched_setscheduler_nocheck(current, SCHED_FIFO, ¶m); if (ret) pr_err("%s: set priority failed\n", __func__); ev = (struct mdss_dsi_event *)data; /* event */ init_waitqueue_head(&ev->event_q); spin_lock_init(&ev->event_lock); while (1) { wait_event(ev->event_q, (ev->event_pndx != ev->event_gndx)); spin_lock_irqsave(&ev->event_lock, flag); evq = &ev->todo_list[ev->event_gndx++]; todo = evq->todo; ctrl = evq->ctrl; evq->todo = 0; ev->event_gndx %= DSI_EVENT_Q_MAX; spin_unlock_irqrestore(&ev->event_lock, flag); pr_debug("%s: ev=%x\n", __func__, todo); #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG) xlog(__func__, todo, 0, 0, 0, 0, 0); #endif if (todo & DSI_EV_PLL_UNLOCKED) mdss_dsi_pll_relock(ctrl); if (todo & DSI_EV_MDP_FIFO_UNDERFLOW) { if (ctrl->recovery) { mdss_dsi_sw_reset_restore(ctrl); ctrl->recovery->fxn(ctrl->recovery->data); } } if (todo & DSI_EV_MDP_BUSY_RELEASE) { spin_lock_irqsave(&ctrl->mdp_lock, flag); ctrl->mdp_busy = false; mdss_dsi_disable_irq_nosync(ctrl, DSI_MDP_TERM); complete(&ctrl->mdp_comp); spin_unlock_irqrestore(&ctrl->mdp_lock, flag); /* enable dsi error interrupt */ mdss_dsi_err_intr_ctrl(ctrl, DSI_INTR_ERROR_MASK, 1); } } return 0; }
/* * E8. [Go down a floor.] This step is like E7 with directions reversed, and also * the times 51 and 14 are changed to 61 and 23, respectively. (It takes the * elevator longer to go down than up.) */ void E8A(void) { int j; int all_zero = 1; for (j = MIN_FLOOR; j < FLOOR; j++) { if (CALLUP[j] || CALLDOWN[j] || CALLCAR[j]) { /** the car need not go downstairs anymore * because nobody's there and nobody's getting there */ all_zero = 0; break; } } xlog(LOG_E, "E8A(). " "FLOOR:%d. CALLCAR[%d]:%d. " "CALLUP[%d]:%d. CALLDOWN[%d]:%d. " "CALLUP[0..4]:%d,%d,%d,%d,%d. " "CALLDOWN[0..4]:%d,%d,%d,%d,%d." "CALLCAR[0..4]:%d,%d,%d,%d,%d.\n", FLOOR, FLOOR, CALLCAR[FLOOR], FLOOR, CALLUP[FLOOR], FLOOR, CALLDOWN[FLOOR], CALLUP[0], CALLUP[1], CALLUP[2], CALLUP[3], CALLUP[4], CALLDOWN[0], CALLDOWN[1], CALLDOWN[2], CALLDOWN[3], CALLDOWN[4], CALLCAR[0], CALLCAR[1], CALLCAR[2], CALLCAR[3], CALLCAR[4]); if (CALLCAR[FLOOR] || CALLDOWN[FLOOR] || ((FLOOR == 2 || CALLUP[FLOOR]) && all_zero)) { in_WAIT(TIME + 23, E2, NO_ARG); /** change state */ return; } else { E8(); /** repeat E8 */ } }
/** ptr: &uinfo[] */ void U1(struct user_info * p) { xlog(LOG_U, "U1(). %s arrives at floor %d, destination is %d.\n", p->name, p->IN, p->OUT); U2(p); }
/* * E7. [Go up a floor.] Set FLOOR <-- FLOOR + 1 and wait 51 units of time. If * now CALLCAR[FLOOR] == 1 or CALLUP[FLOOR] == 1, or * if ((FLOOR == 2 or CALLDOWN[FLOOR] == 1) and * CALLUP[j] == CALLDOWN[j] == CALLCAR[j] == 0 for all j > FLOOR), * wait 14 units (for deceleration) and go to E2. Otherwise, * repeat this step. */ void E7A(void) { int j; int all_zero = 1; for (j = MAX_FLOOR; j > FLOOR; j--) { if (CALLUP[j] || CALLDOWN[j] || CALLCAR[j]) { all_zero = 0; break; } } if (CALLCAR[FLOOR] || CALLUP[FLOOR] || ((FLOOR == 2 || CALLDOWN[FLOOR]) && all_zero)) { xlog(LOG_E, "E7A(). " "FLOOR:%d. CALLCAR[%d]:%d. " "CALLUP[%d]:%d. CALLDOWN[%d]:%d. " "CALLUP[0..4]:%d,%d,%d,%d,%d. " "CALLDOWN[0..4]:%d,%d,%d,%d,%d." "CALLCAR[0..4]:%d,%d,%d,%d,%d.\n", FLOOR, FLOOR, CALLCAR[FLOOR], FLOOR, CALLUP[FLOOR], FLOOR, CALLDOWN[FLOOR], CALLUP[0], CALLUP[1], CALLUP[2], CALLUP[3], CALLUP[4], CALLDOWN[0], CALLDOWN[1], CALLDOWN[2], CALLDOWN[3], CALLDOWN[4], CALLCAR[0], CALLCAR[1], CALLCAR[2], CALLCAR[3], CALLCAR[4]); in_WAIT(TIME + 14, E2, NO_ARG); /** change state */ return; } else { E7(); /** repeat E7 */ } }
/* * E3. [Open doors.] Set D1 and D2 to any nonzero values. Set elevator activity * E9 to start up independently after 300 units of time. (This activity may be * canceled in step E6 below before it occurs. If it has already been scheduled * and not canceled, we cancel it and reschedule it.) Also set elevator activity * E5 to start up independently after 76 units of time. Then wait 20 units of * time (to simulate opening of the doors) and go to E4. */ void E3(void) { xlog(LOG_E, "E3(). Open doors.\n"); D1 = 1; D2 = 1; if (dormant) { dormant = 0; xlog(LOG_E, "E3(). Elevator no more dormant.\n"); } in_WAIT(TIME + 20, E4, NO_ARG); /** let people out, in */ in_WAIT(TIME + 76, E5, NO_ARG); /** close doors */ out_WAIT(E9, 0); /** cancel E9 if it has been scheduled */ in_WAIT(TIME + 300, E9, NO_ARG); /** set inaction indicator */ }
int mHalJpgDecParser(unsigned char* srcAddr, unsigned int srcSize) { pthread_mutex_lock(&resMutex); if(jpgDecoder != NULL) { xlog("hw decoder is busy"); pthread_mutex_unlock(&resMutex); //return JPEG_ERROR_INVALID_DRIVER; return MHAL_INVALID_RESOURCE; } jpgDecoder = new JpgDecHal(); pthread_mutex_unlock(&resMutex); if(!jpgDecoder->lock()) { return return_false("can't lock resource"); } jpgDecoder->setSrcAddr(srcAddr); jpgDecoder->setSrcSize(srcSize); if(!jpgDecoder->parse()) { return return_false("no support file format"); } return 0; }
/** * from_local - determine whether request comes from the local system * @sap: pointer to socket address to check * * With virtual hosting, each hardware network interface can have * multiple network addresses. On such machines the number of machine * addresses can be surprisingly large. * * We also expect the local network configuration to change over time, * so call getifaddrs(3) more than once, but not too often. * * Returns TRUE if the sockaddr contains an address of one of the local * network interfaces. Otherwise FALSE is returned. */ int from_local(const struct sockaddr *sap) { static struct ifaddrs *ifaddr = NULL; static time_t last_update = 0; struct ifaddrs *ifa; unsigned int count; time_t now; if (time(&now) == ((time_t)-1)) { xlog(L_ERROR, "%s: time(2): %m", __func__); /* If we don't know what time it is, use the * existing ifaddr list, if one exists */ now = last_update; if (ifaddr == NULL) now++; } if (now != last_update) { xlog(D_GENERAL, "%s: updating local if addr list", __func__); if (ifaddr) freeifaddrs(ifaddr); if (getifaddrs(&ifaddr) == -1) { xlog(L_ERROR, "%s: getifaddrs(3): %m", __func__); return FALSE; } last_update = now; } count = 0; for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) { if ((ifa->ifa_flags & IFF_UP) && nfs_compare_sockaddr(sap, ifa->ifa_addr)) { xlog(D_GENERAL, "%s: incoming address matches " "local interface address", __func__); return TRUE; } else count++; } xlog(D_GENERAL, "%s: checked %u local if addrs; " "incoming address not found", __func__, count); return FALSE; }
int proxenet_ruby_initialize_function(plugin_t* plugin, req_t type) { /* checks */ if (!plugin->name) { xlog(LOG_ERROR, "%s\n", "null plugin name"); return -1; } if (proxenet_ruby_load_file(plugin) < 0) { xlog(LOG_ERROR, "Failed to load %s\n", plugin->filename); return -1; } /* get function ID */ switch(type) { case REQUEST: if (plugin->pre_function) { xlog(LOG_WARNING, "Pre-hook function already defined for '%s'\n", plugin->name); return 0; } plugin->pre_function = (void*) rb_intern(CFG_REQUEST_PLUGIN_FUNCTION); if (plugin->pre_function) { #ifdef DEBUG xlog(LOG_DEBUG, "Loaded %s:%s\n", plugin->filename, CFG_REQUEST_PLUGIN_FUNCTION); #endif return 0; } break; case RESPONSE: if (plugin->post_function) { xlog(LOG_WARNING, "Post-hook function already defined for '%s'\n", plugin->name); return 0; } plugin->post_function = (void*) rb_intern(CFG_RESPONSE_PLUGIN_FUNCTION); if (plugin->post_function) { #ifdef DEBUG xlog(LOG_DEBUG, "Loaded %s:%s\n", plugin->filename, CFG_RESPONSE_PLUGIN_FUNCTION); #endif return 0; } break; default: xlog(LOG_CRITICAL, "%s\n", "Should never be here, autokill !"); abort(); break; } xlog(LOG_ERROR, "%s\n", "Failed to find function"); return -1; }
void show_prof(void) { int n,m; double proz; int tab[100]; #ifdef BIGPROF unsigned long long total=0; #endif for (n=0; n<100; n++) { tab[n]=n; } qsort(tab,100,sizeof(int),profsort); xlog("----- Profile: -----"); for (n=1; n<100; n++) { m=tab[n]; if (!proftab[m].cycles) break; proz=100.0/proftab[0].cycles*proftab[m].cycles; if (proz<0.1) break; xlog("%-13.13s %5.2f%%",profname[m],proz); } xlog("--------------------"); showmem(); #ifdef BIGPROF qsort(prof,maxprof,sizeof(struct profile),profcomp); for (n=0; n<maxprof; n++) if (!prof[n].task[1]) total+=prof[n].cycles; for (n=0; n<maxprof; n++) { for (m=0; m<10 && prof[n].task[m]; m++) { printf("%s ",profname[prof[n].task[m]]); } printf("%llu calls, %llu cycles, %.2f%%\n",prof[n].calls,prof[n].cycles,100.0/total*prof[n].cycles); } bzero(prof,sizeof(prof)); maxprof=0; #endif //xcheck(); xlog("serials: char=%d, item=%d",sercn,serin); }
void mdss_dsi_clk_req(struct mdss_dsi_ctrl_pdata *ctrl, int enable) { #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG) xlog(__func__,ctrl->ndx, enable, ctrl->mdp_busy, 0x111, 0, current->pid); #endif if (enable == 0) { /* need wait before disable */ mutex_lock(&ctrl->cmd_mutex); mdss_dsi_cmd_mdp_busy(ctrl); mutex_unlock(&ctrl->cmd_mutex); } #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG) xlog(__func__,ctrl->ndx, enable, ctrl->mdp_busy, 0x222, 0, current->pid); #endif mdss_dsi_clk_ctrl(ctrl, enable); }
/** * DNS solve a host name to its IP address. If `type` argument is -1, IP address * return can be of any type (AF_INET or AF_INET6). If type is specified and solved * type do not match, return an error. * * @param host name to solve * @param IP address type to enforce, -1 for any type * @return a pointer to the IP address, or NULL if an error occured */ char* proxenet_resolve_hostname(char* hostname, int type) { struct hostent *hostent; hostent = gethostbyname(hostname); if(!hostent){ xlog(LOG_ERROR, "Failed to solve '%s': %s\n", hostname, strerror(h_errno)); return NULL; } if( (type != -1) && (type != hostent->h_addrtype) ){ xlog(LOG_ERROR, "IP address type wanted (%d) does not match the received (%d)\n", type, hostent->h_addrtype); return NULL; } return hostent->h_addr_list[0]; }
void generic_http_error_page(sock_t sock, char* msg) { char* html_header = "<html><body><h1>proxenet error page</h1><br/>"; char* html_footer = "</body></html>"; if (write(sock, html_header, strlen(html_header)) < 0) { xlog(LOG_ERROR, "%s\n", "Failed to write error HTML header"); } if(write(sock, msg, strlen(msg)) < 0){ xlog(LOG_ERROR, "%s\n", "Failed to write error HTML page"); } if(write(sock, html_footer, strlen(html_footer)) < 0){ xlog(LOG_ERROR, "%s\n", "Failed to write error HTML footer"); } }
/* * If a port is specified on the command line, that port value will be * the same for all listeners created here. Create each listener * socket in advance and set SO_REUSEADDR, rather than allowing the * RPC library to create the listeners for us on a randomly chosen * port via svc_tli_create(RPC_ANYFD). * * Some callers want to listen for more than one RPC version using the * same port number. For example, mountd could want to listen for MNT * version 1, 2, and 3 requests. This means mountd must use the same * set of listener sockets for multiple RPC versions, since, on one * system, you can't have two listener sockets with the exact same * bind address (and port) and transport protocol. * * To accomplish this, this function caches xprts as they are created. * This cache is checked to see if a previously created xprt can be * used, before creating a new xprt for this [program, version]. If * there is a cached xprt with the same bindaddr and transport * semantics, we simply register the new version with that xprt, * rather than creating a fresh xprt for it. * * The xprt cache implemented here is local to a process. Two * separate RPC daemons can not share a set of listeners. * * Returns the count of started listeners (one or zero). */ static unsigned int svc_create_nconf_fixed_port(const char *name, const rpcprog_t program, const rpcvers_t version, void (*dispatch)(struct svc_req *, SVCXPRT *), const uint16_t port, struct netconfig *nconf) { struct addrinfo *ai; SVCXPRT *xprt; ai = svc_create_bindaddr(nconf, port); if (ai == NULL) return 0; xprt = svc_create_find_xprt(ai->ai_addr, nconf); if (xprt == NULL) { int fd; fd = svc_create_sock(ai->ai_addr, ai->ai_addrlen, nconf); if (fd == -1) goto out_free; xprt = svc_tli_create(fd, nconf, NULL, 0, 0); if (xprt == NULL) { xlog(D_GENERAL, "Failed to create listener xprt " "(%s, %u, %s)", name, version, nconf->nc_netid); (void)close(fd); goto out_free; } } if (!svc_reg(xprt, program, version, dispatch, nconf)) { /* svc_reg(3) destroys @xprt in this case */ xlog(D_GENERAL, "Failed to register (%s, %u, %s)", name, version, nconf->nc_netid); goto out_free; } svc_create_cache_xprt(xprt); freeaddrinfo(ai); return 1; out_free: freeaddrinfo(ai); return 0; }
int proxenet_initialize_plugins_list() { if(proxenet_create_list_plugins(cfg->plugins_path) < 0) { xlog(LOG_ERROR, "%s\n", "Failed to build plugins list, leaving"); return -1; } if(cfg->verbose) { xlog(LOG_INFO, "%s\n", "Plugins loaded"); if (cfg->verbose > 1) { xlog(LOG_INFO, "%d plugin(s) found\n", proxenet_plugin_list_size()); proxenet_print_plugins_list(-1); } } return 0; }
/* This list basically indicates what node(s) is/are transmitting on the * medium. It is up to the sub class of PhysicalMedium to make the decision * as to whether there are collisions or not. */ void PhysicalMedium::addNodeToTxList(DeviceNode* node) { assert(node); xlog(LOG_DEBUG, "%s: Add Node ID (0x%016llx) to Tx list", pimpl->name, node->getNodeId()); pimpl->txList.push_back(node); }
/** * realloc(3) wrapper. Checks size and zero-fill buffer. * * @param oldptr: pointer to previous area * @param new_size: new size to allocate * @return a pointer to resized pointer */ void* proxenet_xrealloc(void* oldptr, size_t new_size) { void *newptr; if (new_size > (SIZE_MAX / sizeof(size_t))) { xlog(LOG_CRITICAL, "proxenet_xrealloc: try to allocate incorrect size (%d byte)\n", new_size); abort(); } newptr = realloc(oldptr, new_size); if (newptr == NULL) { xlog(LOG_CRITICAL, "proxenet_xrealloc() failed to allocate space: %s\n", strerror(errno)); abort(); } return newptr; }
/** * Check and change a plugin prority. * * @param p is the reference to the plugin to update * @param prority is the new prority to apply * @return 0 upon success, or -1 if a check has failed. */ int proxenet_plugin_set_prority(unsigned short plugin_id, unsigned short priority) { plugin_t* plugin; plugin_t* p; bool has_changed; plugin = proxenet_get_plugin_by_id( plugin_id ); if (!plugin) return -1; if (priority==0 || priority>=10) return -1; if (!plugins_list) return -1; if (!plugin) return -1; /* 1. unlink `plugin` */ has_changed = false; for (p=plugins_list; p!=NULL; p=p->next){ if (p->next == plugin){ p->next = plugin->next; has_changed = true; break; } } if (!has_changed) return -1; /* 2. relink `plugin` in its new position */ has_changed = false; for (p=plugins_list; p!=NULL; p=p->next){ if (p->priority > priority) continue; plugin->next = p->next; p->next = plugin; plugin->priority = priority; has_changed = true; } if (!has_changed) return -1; if (cfg->verbose){ xlog(LOG_INFO, "Plugin %hu '%s' has a priority of %hu\n", plugin->id, plugin->name, plugin->priority); } return 0; }
void soultrans_equipment(int cn,int in,int in2) { int stren,rank,ran; rank=it[in].data[0]; while (rank) { stren=RANDOM(rank+1); rank-=stren; if (it[in].flags&IF_WEAPON) ran=RANDOM(27); else ran=RANDOM(26); switch(ran) { case 0: it[in2].hp[2]+=stren*25; it[in2].hp[0]+=stren*5; break; case 1: it[in2].mana[2]+=stren*25; it[in2].mana[0]+=stren*5; break; case 2: case 3: case 4: case 5: case 6: over_add(it[in2].attrib[ran-2][2],stren*3); it[in2].attrib[ran-2][0]+=stren/2; break; case 7: over_add(it[in2].skill[SK_DAGGER][2],stren*5); it[in2].skill[SK_DAGGER][0]+=stren; break; case 8: over_add(it[in2].skill[SK_SWORD][2],stren*5); it[in2].skill[SK_SWORD][0]+=stren; break; case 9: over_add(it[in2].skill[SK_TWOHAND][2],stren*5); it[in2].skill[SK_TWOHAND][0]+=stren; break; case 10: over_add(it[in2].skill[SK_STEALTH][2],stren*5); it[in2].skill[SK_STEALTH][0]+=stren; break; case 11: over_add(it[in2].skill[SK_MSHIELD][2],stren*5); it[in2].skill[SK_MSHIELD][0]+=stren; break; case 12: over_add(it[in2].skill[SK_PROTECT][2],stren*5); it[in2].skill[SK_PROTECT][0]+=stren; break; case 13: over_add(it[in2].skill[SK_ENHANCE][2],stren*5); it[in2].skill[SK_ENHANCE][0]+=stren; break; case 14: over_add(it[in2].skill[SK_STUN][2],stren*5); it[in2].skill[SK_STUN][0]+=stren; break; case 15: over_add(it[in2].skill[SK_CURSE][2],stren*5); it[in2].skill[SK_CURSE][0]+=stren; break; case 16: over_add(it[in2].skill[SK_BLESS][2],stren*5); it[in2].skill[SK_BLESS][0]+=stren; break; case 17: over_add(it[in2].skill[SK_RESIST][2],stren*5); it[in2].skill[SK_RESIST][0]+=stren; break; case 18: over_add(it[in2].skill[SK_BLAST][2],stren*5); it[in2].skill[SK_BLAST][0]+=stren; break; case 19: over_add(it[in2].skill[SK_HEAL][2],stren*5); it[in2].skill[SK_HEAL][0]+=stren; break; case 20: over_add(it[in2].skill[SK_GHOST][2],stren*5); it[in2].skill[SK_GHOST][0]+=stren; break; case 21: over_add(it[in2].skill[SK_IMMUN][2],stren*5); it[in2].skill[SK_IMMUN][0]+=stren; break; case 22: over_add(it[in2].skill[SK_SURROUND][2],stren*5); it[in2].skill[SK_SURROUND][0]+=stren; break; case 23: over_add(it[in2].skill[SK_CONCEN][2],stren*5); it[in2].skill[SK_CONCEN][0]+=stren; break; case 24: over_add(it[in2].skill[SK_WARCRY][2],stren*5); it[in2].skill[SK_WARCRY][0]+=stren; break; case 25: it[in2].armor[0]+=stren/2; break; case 26: it[in2].weapon[0]+=stren/2; break; default: xlog("should never happen in soultrans_equipment()"); break; } } it[in2].temp=0; it[in2].flags|=IF_UPDATE|IF_IDENTIFIED|IF_NOREPAIR|IF_SOULSTONE; it[in2].min_rank=max(it[in].data[0],it[in2].min_rank); if (!it[in2].max_damage) it[in2].max_damage=60000; souldestroy(cn,in); sprintf(it[in2].description,"A %s enhanced by a rank %d soulstone.",it[in2].name,it[in].data[0]); }
/** * Identify the protocol to use from the request header * @return a proto_t value if defined/found, -1 otherwise */ static int get_http_protocol(request_t *req) { char *ptr, *ptr2; ptr2 = strstr(req->data, CRLF); if(!ptr2) goto invalid_http_protocol; /* Move to beginning of URL */ for(ptr=req->data; ptr && *ptr!=' ' && *ptr!='\x00' && ptr < ptr2; ptr++); if(!ptr || *ptr!=' ') goto invalid_http_protocol; ++ptr; if(*ptr=='/'){ /* this indicates that the request is well formed already */ /* this case would happen only when using transparent mode */ return TRANSPARENT; } if( strncmp(ptr, HTTP_PROTO_STRING, sizeof(HTTP_PROTO_STRING)-1)==0 ){ /* Check if the requested URL starts with 'http://' */ req->http_infos.proto_type = HTTP; return HTTP; } else if( strncmp(ptr, HTTPS_PROTO_STRING, sizeof(HTTPS_PROTO_STRING)-1)==0 ){ /* Check if the requested URL starts with 'https://' */ req->http_infos.proto_type = HTTPS; return HTTPS; } else if( strncmp(ptr, WS_PROTO_STRING, sizeof(WS_PROTO_STRING)-1)==0 ){ /* Check if the requested URL starts with 'WS://' */ req->http_infos.proto_type = WS; return WS; } invalid_http_protocol: xlog(LOG_ERROR, "%s\n", "Request is not a valid HTTP(S)/WS(S) request"); if (cfg->verbose > 1) xlog(LOG_ERROR, "The invalid request is:\n%s\n", req); return -1; }
void rtsp_tcp_read_cb(struct ev_loop *loop, ev_io *w, ATTR_UNUSED int revents) { guint8 buffer[RTSP_BUFFERSIZE + 1] = { 0, }; /* +1 to control the final '\0' */ int read_size; RTSP_Client *rtsp = w->data; int sd = rtsp->sd; /* if we're receiving data for an HTTP tunnel, we have to run it through the HTTP client's buffer. */ if ( rtsp->pair != NULL ) rtsp = rtsp->pair->http_client; if ( (read_size = recv(sd, buffer, sizeof(buffer), 0) ) <= 0 ) goto client_close; stats_account_read(rtsp, read_size); if (rtsp->input->len + read_size > RTSP_BUFFERSIZE) { xlog(LOG_DBG, "RTSP buffer overflow (input RTSP message is most likely invalid).\n"); goto server_close; } g_byte_array_append(rtsp->input, (guint8*)buffer, read_size); xlog(LOG_DBG, "rtsp request probe is %d. localhost:%s remote:%s", rtsp->pending_request, rtsp->local_host, rtsp->remote_host); RTSP_handler(rtsp); return; client_close: xlog(LOG_INF, "RTSP connection closed by client."); goto disconnect; server_close: xlog(LOG_INF, "RTSP connection closed by server."); goto disconnect; disconnect: ev_unloop(loop, EVUNLOOP_ONE); }
LVAL xlc_log(void) { double arg1 = getflonum(xlgaflonum()); double result; xllastarg(); result = xlog(arg1); return cvflonum(result); }
char * redis_dir_to_namespace(char *s, char cho, char chn) { char *s_base = s; xlog("redis_dir_to_namespace", "s=%s cho=%c chn=%c\n", s, cho, chn); if(!s) return NULL; while(*s) { xlog("WTF", "%c\n", *s); if(*s == cho) *s = chn; s++; } xlog("BUF", "%s\n", s); return s_base; }
/** * Fill buflen-sized buffer with zeroes * * @param buf : buffer to zero-ize * @param buflen : buf length */ void proxenet_xzero(void* buf, size_t buflen) { if (!buf) { xlog(LOG_CRITICAL, "Trying to zero-ify NULL pointer %p\n", buf); abort(); } memset(buf, 0, buflen); }
int get_events(DC& container) { xlog("get_events"); GetEventSender sender; container.for_each_active(TYPE_CAN,&sender); return 0; }
/** * malloc(3) wrapper. Checks size and zero-fill buffer. * * Note: (re-)allocation is a "succeed-or-die" process in proxenet. * * @param size: buffer size to allocate on heap * @return ptr: allocated zero-filled buffer pointer */ void* proxenet_xmalloc(size_t size) { void *ptr; if (size > SIZE_MAX / sizeof(size_t)) { xlog(LOG_CRITICAL, "proxenet_xmalloc: try to allocate incorrect size (%d byte)\n", size); abort(); } ptr = malloc(size); if ( ptr == NULL ) { xlog(LOG_CRITICAL, "%s\n", "proxenet_xmalloc: fail to allocate space"); abort(); } proxenet_xzero(ptr, size); return ptr; }
/** * This function is called when proxenet is loaded. Therefore, only the scripts * located in the `autoload_path` must be loaded. * Additionnal plugins can be added via the command line client. * * @return 0 on success * @return -1 on error */ int proxenet_initialize_plugins_list() { /* NULL as 2nd arg means to try to add all valid plugins from the path */ if(proxenet_add_new_plugins(cfg->autoload_path, NULL) < 0) { xlog(LOG_CRITICAL, "%s\n", "Failed to build plugins list, leaving"); return -1; } if(cfg->verbose) { xlog(LOG_INFO, "%s\n", "Plugins loaded"); if (cfg->verbose > 1) { xlog(LOG_INFO, "%d plugin(s) found\n", proxenet_plugin_list_size()); proxenet_print_plugins_list(-1); } } return 0; }
void count_chestboxes(void) { int x,y,in; for (y=0; y<MAXMAP; y++) { for (x=0; x<MAXMAP; x++) { if (!(in=map[x+y*MAXMAP].it)) continue; if (it[in].driver!=IDR_LAB5_ITEM || it[in].drdata[0]!=3) continue; it[in].drdata[2]=numchestboxes++; } } if (numchestboxes>255) { xlog("too many chestboxes in lab5."); } sizeofchestboxes=(numchestboxes+7)/8; xlog("found %d chests in lab5 (%d bytes)",numchestboxes,sizeofchestboxes); }
static ssize_t proxenet_ioctl(ssize_t (*func)(), sock_t sock, void *buf, size_t count) { int retcode = (*func)(sock, buf, count); if (retcode < 0) { xlog(LOG_ERROR, "Error while I/O plaintext data: %s\n", strerror(errno)); return -1; } return retcode; }
void get_windowed_ins_probs2(int win_length) { // Allocate two arrays for ins. prob over each window of length win_length over each sequence. double* winned_ins_probs1 = (double*)malloc(sizeof(double) * global_aln_info.length1 - win_length + 1); double* winned_ins_probs2 = (double*)malloc(sizeof(double) * global_aln_info.length2 - win_length + 1); char win_ins_prob_file_name[100]; sprintf(win_ins_prob_file_name, "win_ins_probs1_%d.txt", win_length); FILE* win_ins_prob_file = fopen(win_ins_prob_file_name, "w"); for(int cnt1 = 1; cnt1 < global_aln_info.length1 - win_length + 1; cnt1++) { // cnt1 is the index of starting of current window. winned_ins_probs1[cnt1] = LOG_OF_ZERO; // cnt2 is the index in second sequence where window is betweenm i.e., // the window is assumed to be inserted between cnt2 and cnt2 + 1. // however I do not put the constraint that cnt1-1 is not aligned to cnt2 and cnt2 is not aligned to // cnt1 + win_length + 1. for(int cnt2 = 1; cnt2 < global_aln_info.length2 + 1; cnt2++) { // cur_win_ins_prob includes probability of all enumerations of alignments where // currently set window is inserted in first sequences. double cur_win_ins_prob = xlog_mul(global_aln_info.fore_hmm_array->probs[cnt1][cnt2][STATE_INS1], global_aln_info.back_hmm_array->probs[cnt1 + win_length][cnt2][STATE_INS1]); // Calculate the emission probability of inserted sequence by going over all inserted sequence. // emit the nucleotides in the inserted sequence is sequence 1. double int_emit_prob = xlog(1); for(int emit_cnt = cnt1 + 1; emit_cnt <= cnt1 + win_length; emit_cnt++) { double trans_emit_prob; if(emit_cnt == cnt1 + win_length) { trans_emit_prob = get_trans_emit_prob(STATE_INS1, STATE_INS1, emit_cnt, cnt2); } else { trans_emit_prob = get_trans_emit_prob(STATE_INS1, STATE_INS1, emit_cnt, cnt2); } int_emit_prob = xlog_mul(int_emit_prob, trans_emit_prob); } cur_win_ins_prob = xlog_mul(cur_win_ins_prob, int_emit_prob); winned_ins_probs1[cnt1] = xlog_sum(winned_ins_probs1[cnt1], cur_win_ins_prob); } fprintf(win_ins_prob_file, "%f ", xlog_div(winned_ins_probs1[cnt1], global_aln_info.op_prob)); } fprintf(win_ins_prob_file, "\n"); fclose(win_ins_prob_file); }
void * PhysicalMedium::run() { pimpl->state = IDLE; if (clock_gettime(pimpl->clockidToUse, &pimpl->curTime) == -1) throw "clock_gettime: unrecoverable error"; do { if (pimpl->state == IDLE) { interval(1000); if(pimpl->state == STOPPING) break; if (!pimpl->txList.empty()) pimpl->state = TX_802514_FRAME; // Process CCA List processCcaList(); } // In this loop we wait until the Tx list is empty. During this // time if we get more than 1 node in the Tx List we have a // collision. while (!pimpl->txList.empty()) { // TODO: Maybe use timerfd to get finer resolution with // Tx Packet Timings. interval(1); if(pimpl->state == STOPPING) break; // Process CCA List, as we are in state TX_802514_FRAME // This routine will tell nodes they have failed CCA. processCcaList(); // Check with subclasses collision check, this needs to // be done before we check timeouts as if a tx timer // expires it will check for collisions and arm the // next packet to tx member variable. txCollisionCheck(); // Go through Tx list and process timers and if one has // expired send the Tx Done Indication with the result // of the transmission. processTxList(); } if(pimpl->state != STOPPING) { /* Check for nodes that have expired registration period */ pimpl->state = IDLE; checkNodeRegistrationTimeout(); } } while(pimpl->state != STOPPING); xlog(LOG_NOTICE, "Network Simulator Stopped"); pimpl->state = STOPPED; return 0; }