Changeset 3210
- Timestamp:
- 09/24/10 10:25:46 (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r3205 r3210 408 408 //int s_port; 409 409 in_addr_t s_ip; 410 void (*s_handler)();410 void *(*s_handler)(); 411 411 int (*recv)(); 412 412 void (*send_dcw)(); -
trunk/module-camd33.c
r3192 r3210 177 177 } 178 178 179 static void camd33_server(void* idx)179 static void * camd33_server(void* cli) 180 180 { 181 181 int n; 182 182 uchar mbuf[1024]; 183 183 184 int cidx=(int)idx;185 client [cidx].thread=pthread_self();186 187 client [cs_idx].req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE);188 if (!client [cs_idx].req)184 struct s_client * client = (struct s_client *) cli; 185 client->thread=pthread_self(); 186 187 client->req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE); 188 if (!client->req) 189 189 { 190 190 cs_log("Cannot allocate memory (errno=%d)", errno); 191 191 cs_exit(1); 192 192 } 193 memset(client [cs_idx].req, 0, CS_MAXPENDING*REQ_SIZE);193 memset(client->req, 0, CS_MAXPENDING*REQ_SIZE); 194 194 195 195 camd33_auth_client(); … … 210 210 } 211 211 cs_disconnect_client(); 212 return NULL; 212 213 } 213 214 -
trunk/module-camd35.c
r3192 r3210 293 293 } 294 294 295 static void camd35_server(void *idx)295 static void * camd35_server(void *cli) 296 296 { 297 297 int n; 298 298 uchar mbuf[1024]; 299 299 300 int cidx=(int)idx;301 client [cidx].thread=pthread_self();302 303 client [cs_idx].req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE);304 if (!client [cs_idx].req)300 struct s_client * client = (struct s_client *) cli; 301 client->thread=pthread_self(); 302 303 client->req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE); 304 if (!client->req) 305 305 { 306 306 cs_log("Cannot allocate memory (errno=%d)", errno); 307 307 cs_exit(1); 308 308 } 309 memset(client [cs_idx].req, 0, CS_MAXPENDING*REQ_SIZE);310 311 client [cs_idx].is_udp = (ph[client[cs_idx].ctyp].type == MOD_CONN_UDP);309 memset(client->req, 0, CS_MAXPENDING*REQ_SIZE); 310 311 client->is_udp = (ph[client[cs_idx].ctyp].type == MOD_CONN_UDP); 312 312 313 313 while ((n=process_input(mbuf, sizeof(mbuf), cfg->cmaxidle))>0) … … 328 328 } 329 329 330 if(client [cs_idx].req) { free(client[cs_idx].req); client[cs_idx].req=0;}330 if(client->req) { free(client[cs_idx].req); client[cs_idx].req=0;} 331 331 332 332 cs_disconnect_client(); 333 return NULL; //to prevent compiler message 333 334 } 334 335 -
trunk/module-cccam.c
r3209 r3210 2813 2813 } 2814 2814 2815 void cc_srv_init() {2815 void * cc_srv_init() { 2816 2816 struct s_client *cl = &client[cs_idx]; 2817 2817 cl->pfd = cl->udp_fd; … … 2823 2823 2824 2824 cs_exit(1); 2825 return NULL; //suppress compiler warning 2825 2826 } 2826 2827 -
trunk/module-dvbapi.c
r3193 r3210 1178 1178 } 1179 1179 1180 void dvbapi_main_local(void *idx) {1181 int cidx=(int)idx;1182 client [cidx].thread=pthread_self();1180 void * dvbapi_main_local(void *cli) { 1181 struct s_client * client = (struct s_client *) cli; 1182 client->thread=pthread_self(); 1183 1183 1184 1184 int maxpfdsize=(MAX_DEMUX*MAX_FILTER)+MAX_DEMUX+2; … … 1194 1194 int ok=0; 1195 1195 if (!account) { 1196 client [cs_idx].usr[0]=0;1196 client->usr[0]=0; 1197 1197 for (ok=0, account=cfg->account; (account) && (!ok); account=account->next) 1198 1198 if( (ok=!strcmp(cfg->dvbapi_usr, account->usr)) ) … … 1214 1214 if (selected_box == -1 || selected_api==-1) { 1215 1215 cs_log("could not detect api version"); 1216 return ;1216 return NULL; 1217 1217 } 1218 1218 … … 1225 1225 if (listenfd < 1) { 1226 1226 cs_log("could not init camd.socket."); 1227 return ;1227 return NULL; 1228 1228 } 1229 1229 } … … 1250 1250 tp.time+=500; 1251 1251 1252 pfd2[0].fd = client [cs_idx].fd_m2c_c;1252 pfd2[0].fd = client->fd_m2c_c; 1253 1253 pfd2[0].events = (POLLIN | POLLPRI); 1254 1254 type[0]=0; … … 1315 1315 continue; 1316 1316 } 1317 if (pfd2[i].fd==client [cs_idx].fd_m2c_c) {1317 if (pfd2[i].fd==client->fd_m2c_c) { 1318 1318 cs_exit(0); 1319 1319 } 1320 1320 } 1321 1321 if (pfd2[i].revents & (POLLIN | POLLPRI)) { 1322 if (pfd2[i].fd==client [cs_idx].fd_m2c_c) {1323 chk_dcw(client [cs_idx].fd_m2c_c);1322 if (pfd2[i].fd==client->fd_m2c_c) { 1323 chk_dcw(client->fd_m2c_c); 1324 1324 continue; 1325 1325 } … … 1368 1368 } 1369 1369 } 1370 return ;1370 return NULL; 1371 1371 } 1372 1372 … … 1477 1477 } 1478 1478 1479 static void dvbapi_handler(int ctyp) {1479 static void * dvbapi_handler(int ctyp) { 1480 1480 //cs_log("dvbapi loaded fd=%d", idx); 1481 1481 if (cfg->dvbapi_enabled == 1) { … … 1485 1485 client[i].ctyp=ctyp; 1486 1486 #ifdef AZBOX 1487 pthread_create(&client[i].thread, NULL, (void *)azbox_main, (void*) i);1487 pthread_create(&client[i].thread, NULL, azbox_main, (void*) &client[i]); 1488 1488 #else 1489 pthread_create(&client[i].thread, NULL, (void *)dvbapi_main_local, (void*) i);1489 pthread_create(&client[i].thread, NULL, dvbapi_main_local, (void*) &client[i]); 1490 1490 #endif 1491 1491 pthread_detach(client[i].thread); 1492 1492 } 1493 1493 1494 return ;1494 return NULL; 1495 1495 } 1496 1496 … … 1601 1601 } 1602 1602 1603 void azbox_main(void *idx) {1604 int cidx=(int)idx;1605 client [cidx].thread=pthread_self();1603 void * azbox_main(void *cli) { 1604 struct s_client * client = (struct s_client *) cli; 1605 client->thread=pthread_self(); 1606 1606 struct timeb tp; 1607 1607 cs_ftime(&tp); … … 1696 1696 openxcas_close(); 1697 1697 cs_log("openxcas: exited"); 1698 return ;1698 return NULL; 1699 1699 break; 1700 1700 case OPENXCAS_UKNOWN_MSG: … … 1707 1707 } 1708 1708 cs_log("openxcas: invalid message"); 1709 return ;1709 return NULL; 1710 1710 } 1711 1711 -
trunk/module-monitor.c
r3193 r3210 763 763 } 764 764 765 static void monitor_server(void *idx){765 static void * monitor_server(void *cli){ 766 766 int n; 767 767 uchar mbuf[1024]; 768 768 769 int cidx=(int)idx;770 client[cidx].thread=pthread_self();771 client [cs_idx].typ='m';769 struct s_client * client = (struct s_client *) cli; 770 client->thread=pthread_self(); 771 client->typ='m'; 772 772 while (((n = process_input(mbuf, sizeof(mbuf), cfg->cmaxidle)) >= 0) && monitor_process_request((char *)mbuf)); 773 773 cs_disconnect_client(); 774 return NULL; 774 775 } 775 776 -
trunk/module-newcamd.c
r3194 r3210 1039 1039 } 1040 1040 1041 static void newcamd_server(void *idx)1041 static void * newcamd_server(void *cli) 1042 1042 { 1043 1043 int rc; 1044 int cidx=(int)idx;1045 client[cidx].thread=pthread_self();1044 struct s_client * client = (struct s_client *) cli; 1045 client->thread=pthread_self(); 1046 1046 uchar mbuf[1024]; 1047 1047 1048 client [cs_idx].req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE);1049 if (!client [cs_idx].req)1048 client->req=(uchar *)malloc(CS_MAXPENDING*REQ_SIZE); 1049 if (!client->req) 1050 1050 { 1051 1051 cs_log("Cannot allocate memory (errno=%d)", errno); … … 1053 1053 } 1054 1054 1055 memset(client [cs_idx].req, 0, CS_MAXPENDING*REQ_SIZE);1056 client [cs_idx].ncd_server = 1;1057 cs_log("client connected to %d port", cfg->ncd_ptab.ports[client [cs_idx].port_idx].s_port);1058 1059 if (cfg->ncd_ptab.ports[client [cs_idx].port_idx].ncd_key_is_set) {1055 memset(client->req, 0, CS_MAXPENDING*REQ_SIZE); 1056 client->ncd_server = 1; 1057 cs_log("client connected to %d port", cfg->ncd_ptab.ports[client->port_idx].s_port); 1058 1059 if (cfg->ncd_ptab.ports[client->port_idx].ncd_key_is_set) { 1060 1060 //port has a des key specified 1061 newcamd_auth_client(client [cs_idx].ip, cfg->ncd_ptab.ports[client[cs_idx].port_idx].ncd_key);1061 newcamd_auth_client(client->ip, cfg->ncd_ptab.ports[client->port_idx].ncd_key); 1062 1062 } else { 1063 1063 //default global des key 1064 newcamd_auth_client(client [cs_idx].ip, cfg->ncd_key);1064 newcamd_auth_client(client->ip, cfg->ncd_key); 1065 1065 } 1066 1066 … … 1078 1078 for (r=0; r<CS_MAXREADER; r++) { 1079 1079 int flt = 0; 1080 if (!(reader[r].grp & client [cs_idx].grp)) continue; //test - skip unaccesible readers1080 if (!(reader[r].grp & client->grp)) continue; //test - skip unaccesible readers 1081 1081 if (reader[r].ftab.filts) { 1082 1082 for (j=0; j<CS_MAXFILTERS; j++) { … … 1087 1087 cs_debug("newcamd: extended: report card"); 1088 1088 1089 network_message_send(client [cs_idx].udp_fd,1090 &client [cs_idx].ncd_msgid, buf, 3,1091 client [cs_idx].ncd_skey, COMMTYPE_SERVER, 0, cd);1089 network_message_send(client->udp_fd, 1090 &client->ncd_msgid, buf, 3, 1091 client->ncd_skey, COMMTYPE_SERVER, 0, cd); 1092 1092 1093 1093 flt = 1; … … 1109 1109 1110 1110 cs_debug("newcamd: extended: report card"); 1111 network_message_send(client [cs_idx].udp_fd,1112 &client [cs_idx].ncd_msgid, buf, 3,1113 client [cs_idx].ncd_skey, COMMTYPE_SERVER, 0, cd);1111 network_message_send(client->udp_fd, 1112 &client->ncd_msgid, buf, 3, 1113 client->ncd_skey, COMMTYPE_SERVER, 0, cd); 1114 1114 } 1115 1115 } … … 1148 1148 if(rc==-9) 1149 1149 { 1150 if (client [cs_idx].ncd_keepalive)1150 if (client->ncd_keepalive) 1151 1151 newcamd_reply_ka(); 1152 1152 else … … 1155 1155 } 1156 1156 1157 if(client [cs_idx].req)1157 if(client->req) 1158 1158 { 1159 free(client [cs_idx].req);1160 client [cs_idx].req=0;1159 free(client->req); 1160 client->req=0; 1161 1161 } 1162 1162 1163 1163 cs_disconnect_client(); 1164 return NULL; 1164 1165 } 1165 1166 -
trunk/module-radegast.c
r3193 r3210 151 151 } 152 152 153 static void radegast_server(void *idx)153 static void * radegast_server(void *cli) 154 154 { 155 155 int n; 156 156 uchar mbuf[1024]; 157 157 158 int cidx=(int)idx;159 client [cidx].thread=pthread_self();158 struct s_client * client = (struct s_client *) cli; 159 client->thread=pthread_self(); 160 160 161 161 radegast_auth_client(client[cs_idx].ip); … … 172 172 } 173 173 cs_disconnect_client(); 174 return NULL; 174 175 } 175 176 -
trunk/module-serial.c
r3195 r3210 1 //FIXME Not threadsafe & running multiple instances !!! 1 2 #include "globals.h" 2 3 #include <termios.h> … … 863 864 } 864 865 865 static void oscam_ser_fork(char *url)866 static void * oscam_ser_fork(void *url2) 866 867 { 867 868 //static char logtxt[32]; 869 char *url = (char *) url2; 868 870 869 871 client[cs_idx].is_server=1; 870 if ((!url) || (!url[0])) return ;871 if (!oscam_ser_parse_url(url)) return ;872 if ((!url) || (!url[0])) return NULL; 873 if (!oscam_ser_parse_url(url)) return NULL; 872 874 // snprintf(logtxt, sizeof(logtxt)-1, ", %s@%s", 873 875 // oscam_ser_proto>P_MAX ? "auto" : proto_txt[oscam_ser_proto], oscam_ser_device); … … 886 888 if (client[cs_idx].pfd) close(client[cs_idx].pfd); 887 889 } 888 } 889 890 void init_oscam_ser(int ctyp) 890 return NULL; 891 } 892 893 void * init_oscam_ser(int ctyp) 891 894 { 892 895 char sdevice[512]; … … 898 901 { 899 902 *p = 0; 900 if ((!p + 1) || (!(p + 1)[0])) return ;901 if (!oscam_ser_parse_url(p + 1)) return ;903 if ((!p + 1) || (!(p + 1)[0])) return NULL; 904 if (!oscam_ser_parse_url(p + 1)) return NULL; 902 905 int i=cs_fork(0, ctyp); 903 906 client[i].typ='c'; 904 907 client[i].ip=0; 905 908 client[i].ctyp=ctyp; 906 pthread_create(&client[i].thread, NULL, (void *)oscam_ser_fork, (void *)p + 1);909 pthread_create(&client[i].thread, NULL, oscam_ser_fork, (void *) p + 1); //FIXME value of p does not survive thread 907 910 pthread_detach(client[i].thread); 908 911 } 909 912 910 if (!sdevice[0]) return ;911 if (!oscam_ser_parse_url(sdevice)) return ;913 if (!sdevice[0]) return NULL; 914 if (!oscam_ser_parse_url(sdevice)) return NULL; 912 915 913 916 int i=cs_fork(0, ctyp); … … 915 918 client[i].ip=0; 916 919 client[i].ctyp=ctyp; 917 pthread_create(&client[i].thread, NULL, (void *)oscam_ser_fork, (void *)sdevice);920 pthread_create(&client[i].thread, NULL, oscam_ser_fork, (void *) sdevice); 918 921 pthread_detach(client[i].thread); 922 return NULL; 919 923 } 920 924 -
trunk/oscam.c
r3209 r3210 2643 2643 2644 2644 //ph[i].s_handler(cad); // never return 2645 pthread_create(&client[o].thread, NULL, (void *)ph[i].s_handler, (void *) o);2645 pthread_create(&client[o].thread, NULL, ph[i].s_handler, (void *) &client[o]); //pass client[o] since o is local variable that will not survive the thread 2646 2646 pthread_detach(client[o].thread); 2647 2647 } else { … … 2676 2676 // alarm(cfg->cmaxidle + cfg->ctimeout / 1000 + 1); 2677 2677 2678 pthread_create(&client[o].thread, NULL, (void *)ph[i].s_handler, (void*) o);2678 pthread_create(&client[o].thread, NULL, ph[i].s_handler, (void*) &client[o]); 2679 2679 pthread_detach(client[o].thread); 2680 2680 } -
trunk/reader-seca.c
r3182 r3210 48 48 int seca_card_init(struct s_reader * reader, ATR newatr) 49 49 { 50 cs_log("DINGO CHECKPOINT 1"); 50 51 get_atr; 51 52 def_resp;
Note:
See TracChangeset
for help on using the changeset viewer.