Changeset 5410
- Timestamp:
- 06/17/11 21:55:29 (13 years ago)
- Location:
- branches/dynamic-threads
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dynamic-threads
-
branches/dynamic-threads/cygwin/WinSCard.h
r5404 r5410 77 77 // Smart Cards. 78 78 // 79 typedef SCARDHANDLE (WINAPI *LPOCNCONNPROCA) (__in SCARDCONTEXT, __in LPSTR, __in LPSTR, __in PVOID); 80 typedef SCARDHANDLE (WINAPI *LPOCNCONNPROCW) (__in SCARDCONTEXT, __in LPWSTR, __in LPWSTR, __in PVOID); 79 typedef ULONG_PTR SCARDCONTEXT; 80 typedef SCARDCONTEXT *PSCARDCONTEXT, *LPSCARDCONTEXT; 81 82 typedef ULONG_PTR SCARDHANDLE; 83 typedef SCARDHANDLE *PSCARDHANDLE, *LPSCARDHANDLE; 81 84 82 85 … … 844 847 #define SCERR_NOGUIDS 0x8000 845 848 849 typedef SCARDHANDLE (WINAPI *LPOCNCONNPROCA) (__in SCARDCONTEXT, __in LPSTR, __in LPSTR, __in PVOID); 850 typedef SCARDHANDLE (WINAPI *LPOCNCONNPROCW) (__in SCARDCONTEXT, __in LPWSTR, __in LPWSTR, __in PVOID); 846 851 #ifdef UNICODE 847 852 #define LPOCNCONNPROC LPOCNCONNPROCW -
branches/dynamic-threads/global-functions.h
r5404 r5410 79 79 extern int32_t check_cwcache2(ECM_REQUEST *, uint64_t grp); 80 80 extern int32_t write_to_pipe(struct s_client *, int32_t, uchar *, int32_t); 81 extern int32_t read_from_pipe( int32_t, uchar **);81 extern int32_t read_from_pipe(struct s_client *, uchar **); 82 82 extern int32_t write_ecm_answer(struct s_reader *, ECM_REQUEST *); 83 83 extern uint32_t chk_provid(uchar *, uint16_t); -
branches/dynamic-threads/module-coolapi.c
r5304 r5410 115 115 return; 116 116 } 117 118 cs_lock(&dmx->mutex); 117 119 118 pthread_setspecific(getclient, dvbapi_client); 119 pthread_mutex_lock(&dmx->mutex); 120 120 ret = coolapi_read(dmx->fd, buffer, len); 121 cs_unlock(&dmx->mutex);121 pthread_mutex_unlock(&dmx->mutex); 122 122 dvbapi_process_input(dmx->demux_id, dmx->filter_num, buffer, len); 123 123 } … … 168 168 memcpy(filter.mask, mask, 12); 169 169 170 cs_lock(&dmx->mutex);170 pthread_mutex_lock(&dmx->mutex); 171 171 if(dmx->filter == NULL) { 172 172 dmx->filter_attached = false; … … 196 196 check_error ("cnxt_dmx_channel_ctrl", result); 197 197 dmx->pid = pid; 198 cs_unlock(&dmx->mutex);198 pthread_mutex_unlock(&dmx->mutex); 199 199 return 0; 200 200 } … … 214 214 cs_debug_mask(D_DVBAPI, "fd %08x channel %x num %d pid %x opened %s", fd, (int) dmx->channel, num, dmx->pid, dmx->opened ? "yes" : "no"); 215 215 216 cs_lock(&dmx->mutex);216 pthread_mutex_lock(&dmx->mutex); 217 217 result = cnxt_dmx_channel_ctrl(dmx->channel, 0, 0); 218 218 check_error ("cnxt_dmx_channel_ctrl", result); … … 225 225 result = cnxt_cbuf_flush (dmx->buffer2, 0); 226 226 check_error ("cnxt_cbuf_flush", result); 227 cs_unlock(&dmx->mutex);227 pthread_mutex_unlock(&dmx->mutex); 228 228 229 229 dmx->pid = -1; -
branches/dynamic-threads/module-monitor.c
r5364 r5410 495 495 if (!strcmp(flag, "on") && loghist){ 496 496 char *t_loghistptr = loghistptr, *ptr1 = NULL; 497 if(loghistptr >= loghist + (cfg.loghistorysize) - 1) 498 t_loghistptr = loghist; 497 499 int32_t l1 = strlen(t_loghistptr+1) + 2; 498 500 char *lastpos = loghist + (cfg.loghistorysize)-1; -
branches/dynamic-threads/oscam-http.c
r5404 r5410 79 79 int32_t k, pos = 0, needed = 1; 80 80 char *value, *dot = ""; 81 int32_t ptr = cl->cwlastresptimes_last; 81 82 82 83 needed = CS_ECM_RINGBUFFER_MAX * 5; //4 digits + delimiter 83 84 if(!cs_malloc(&value, needed * sizeof(char), -1)) return ""; 84 85 85 if( cl->cwlastresptimes_last== CS_ECM_RINGBUFFER_MAX - 1){86 if(ptr == CS_ECM_RINGBUFFER_MAX - 1){ 86 87 for(k = 0; k < CS_ECM_RINGBUFFER_MAX ; k++){ 87 88 pos += snprintf(value + pos, needed-pos, "%s%d", dot, cl->cwlastresptimes[k]); … … 89 90 } 90 91 } else { 91 for(k = cl->cwlastresptimes_last+ 1; k < CS_ECM_RINGBUFFER_MAX; k++){92 for(k = ptr + 1; k < CS_ECM_RINGBUFFER_MAX; k++){ 92 93 pos += snprintf(value + pos, needed-pos, "%s%d", dot, cl->cwlastresptimes[k]); 93 94 dot=","; 94 95 } 95 96 96 for(k = 0; k < cl->cwlastresptimes_last+ 1 ; k++){97 for(k = 0; k < ptr + 1 ; k++){ 97 98 pos += snprintf(value + pos, needed-pos, "%s%d", dot, cl->cwlastresptimes[k]); 98 99 dot=","; … … 1232 1233 } 1233 1234 1234 if (apicall && (strcmp(getParam(params, "ecmhistory"), "1") == 0)) {1235 char *value = get_ecm_historystring(rdr->client);1236 tpl_printf(vars, TPLADD, "ECMHISTORY", "%s", value);1237 free_mk_t(value);1238 }1239 1240 1235 if (!apicall){ 1241 1236 tpl_addVar(vars, TPLADD, "LABEL", rdr->label); … … 2434 2429 if (loghist) { 2435 2430 char *t_loghistptr = loghistptr, *ptr1 = NULL; 2431 if(loghistptr >= loghist + (cfg.loghistorysize) - 1) 2432 t_loghistptr = loghist; 2436 2433 int32_t d = 0, l1 = strlen(t_loghistptr+1) + 2; 2437 2434 char *lastpos = loghist + (cfg.loghistorysize)-1; … … 3018 3015 return tpl_getTpl(vars, "APIERROR"); 3019 3016 } 3017 } else if (strcmp(getParam(params, "part"), "ecmhistory") == 0) { 3018 int32_t i; 3019 int32_t isec; 3020 time_t now = time((time_t)0); 3021 char *usr; 3022 struct s_client *cl; 3023 for (i=0, cl=first_client; cl ; cl=cl->next, i++) { 3024 if ( (cl->typ=='p') || (cl->typ=='r') ) { 3025 tpl_printf(vars, TPLADD, "CLIENTTYPE", "%c", cl->typ); 3026 usr=username(cl); 3027 tpl_addVar(vars, TPLADD, "CLIENTUSER", xml_encode(vars, usr)); 3028 tpl_printf(vars, TPLADD, "CLIENTLASTRESPONSETIME", "%d", cl->cwlastresptime?cl->cwlastresptime:1); 3029 3030 3031 isec = now - cl->last; 3032 tpl_printf(vars, TPLADD, "CLIENTIDLESECS", "%d", isec); 3033 //load historical values from ringbuffer 3034 //char *value = get_ecm_historystring(cl); 3035 //tpl_printf(vars, TPLADD, "CLIENTLASTRESPONSETIMEHIST", "%s", value); 3036 //free_mk_t(value); 3037 tpl_addVar(vars, TPLAPPEND, "APISTATUSBITS", tpl_getTpl(vars, "APISTATUSBIT")); 3038 } 3039 } 3040 return tpl_getTpl(vars, "APISTATUS"); 3020 3041 #ifdef WITH_LB 3021 3042 } else if (strcmp(getParam(params, "part"), "readerstats") == 0) { -
branches/dynamic-threads/oscam-http.h
r5404 r5410 1838 1838 function init(evt) {\n\ 1839 1839 fetch_url=location.search.split('?');\n\ 1840 fetch_url='oscamapi.html?part= status&' + fetch_url[fetch_url.length-1];\n\1840 fetch_url='oscamapi.html?part=ecmhistory&' + fetch_url[fetch_url.length-1];\n\ 1841 1841 SVGDoc = evt.target.ownerDocument;\n\ 1842 1842 fetch_data();\n\ -
branches/dynamic-threads/oscam.c
r5404 r5410 32 32 char cs_confdir[128]=CS_CONFDIR; 33 33 int32_t cs_dblevel=0; // Debug Level 34 int32_t thread_pipe[2]; 34 35 #ifdef WEBIF 35 36 int8_t cs_restart_mode=1; //Restartmode: 0=off, no restart fork, 1=(default)restart fork, restart by webif, 2=like=1, but also restart on segfaults … … 125 126 cl->cwlastresptimes_last++; 126 127 } 127 cl->cwlastresptimes[cl->cwlastresptimes_last] = ltime ;128 cl->cwlastresptimes[cl->cwlastresptimes_last] = ltime > 9999 ? 9999 : ltime; 128 129 } 129 130 … … 1532 1533 return; 1533 1534 #endif 1535 // Check if ecm is outdated and ecmcacheptr thus is invalid (freed from ecmcache), 1536 // We don't calculate with cfg.ctimeout as this may be changed by WebIf and ECMs older than CS_CACHE_TIMEOUT=60s are useless anyway 1537 struct timeb tpe; 1538 cs_ftime(&tpe); 1539 if(tpe.time - er->tps.time - CS_CACHE_TIMEOUT >= 0) return; 1540 1534 1541 struct s_ecm *ecm = er->ecmcacheptr; 1535 if (!ecm || rc >= ecm->rc) return; 1536 1542 if (!ecm || rc >= ecm->rc) return; 1543 1537 1544 //cs_log("store ecm from reader %d", er->selected_reader); 1538 1545 memcpy(ecm->ecmd5, er->ecmd5, CS_ECMSTORESIZE); … … 2946 2953 cl->thread_active=0; 2947 2954 pthread_mutex_unlock(&cl->thread_lock); 2955 if (thread_pipe[1]) 2956 write(thread_pipe[1], mbuf, 1); //wakeup client check 2948 2957 2949 2958 break; … … 3001 3010 3002 3011 void * client_check(void) { 3003 int rc, pfdcount = 0;3012 int32_t i, k, j, rc, pfdcount = 0; 3004 3013 struct s_client *cl; 3005 3014 struct s_reader *rdr; 3006 3015 struct pollfd pfd[1024]; 3007 3016 struct s_client *cl_list[1024]; 3008 int i,k,j; 3017 char buf[10]; 3018 3019 if (pipe(thread_pipe) == -1) { 3020 printf("cannot create pipe, errno=%d\n", errno); 3021 exit(1); 3022 } 3009 3023 3010 3024 while (!exit_oscam) { 3011 3025 pfdcount = 0; 3026 3027 pfd[pfdcount].fd = thread_pipe[0]; 3028 pfd[pfdcount++].events = POLLIN | POLLPRI | POLLHUP; 3012 3029 3013 3030 for (cl=first_client->next; cl ; cl=cl->next) { … … 3046 3063 } 3047 3064 3048 rc = poll(pfd, pfdcount, 500 );3065 rc = poll(pfd, pfdcount, 5000); 3049 3066 3050 3067 if (rc<1) … … 3054 3071 //clients 3055 3072 cl = cl_list[i]; 3073 3074 if (pfd[i].fd == thread_pipe[0] && (pfd[i].revents & (POLLIN | POLLPRI))) { 3075 // a thread ended and cl->pfd should be added to pollfd list again (thread_active==0) 3076 read(thread_pipe[0], buf, sizeof(buf)); 3077 continue; 3078 } 3056 3079 3057 3080 //clients
Note:
See TracChangeset
for help on using the changeset viewer.