Changeset 5098 for trunk/module-cccam.c
- Timestamp:
- 04/27/11 18:58:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r5085 r5098 431 431 if (rc<0) { 432 432 if (errno==EINTR) continue; 433 elsereturn(-1); //error!!433 return(-1); //error!! 434 434 } 435 435 436 436 if(FD_ISSET(cl->udp_fd,&fds)) 437 437 break; 438 else 439 return (-2); //timeout!! 438 return (-2); //timeout!! 440 439 } 441 440 return recv(cl->udp_fd, buf, len, MSG_WAITALL); … … 466 465 return -1; 467 466 467 while (pthread_mutex_trylock(&cc->lockcmd)) { 468 cs_debug_mask(D_TRACE, "%s trylock recv waiting", getprefix()); 469 cs_sleepms(50); 470 } 471 468 472 len = recv(handle, buf, 4, MSG_WAITALL); 469 473 if (rdr) … … 475 479 else 476 480 cs_debug_mask(cl->typ=='c'?D_CLIENT:D_READER, "%s invalid header length (expected 4, read %d)", getprefix(), len); 481 pthread_mutex_unlock(&cc->lockcmd); 477 482 return -1; 478 483 } 479 484 480 pthread_mutex_lock(&cc->lockcmd);481 482 485 cc_crypt(&cc->block[DECRYPT], buf, 4, DECRYPT); 483 486 //cs_ddump_mask(D_CLIENT, buf, 4, "cccam: decrypted header:"); … … 532 535 struct cc_data *cc = cl->cc; 533 536 534 pthread_mutex_lock(&cc->lockcmd); //We need this because cc_cmd_send is called from cccshare 537 while (pthread_mutex_trylock(&cc->lockcmd)) { //We need this because cc_cmd_send is called from cccshare 538 cs_debug_mask(D_TRACE, "%s trylock send waiting", getprefix()); 539 cs_sleepms(50); 540 } 535 541 536 542 memset(netbuf, 0, len + 4); … … 1061 1067 struct timeb timeout; 1062 1068 timeout = cc->ecm_time; 1063 uint32_t tt = cfg.ctimeout * 4;1069 uint32_t tt = cfg.ctimeout+500; 1064 1070 timeout.time += tt / 1000; 1065 1071 timeout.millitm += tt % 1000; … … 1104 1110 cur_srvid.ecmlen = cur_er->l; 1105 1111 1106 pthread_mutex_lock(&cc->cards_busy); 1112 while (pthread_mutex_trylock(&cc->cards_busy)) { 1113 cs_debug_mask(D_TRACE, "%s trylock send_ecm cards waiting", getprefix()); 1114 cs_sleepms(50); 1115 } 1107 1116 //forward_origin: 1108 1117 if (cfg.cc_forward_origin_card && cur_er->origin_reader == rdr && cur_er->origin_card) { … … 1353 1362 1354 1363 //Last used card is first card of current_cards: 1355 pthread_mutex_lock(&cc->cards_busy); 1364 while (pthread_mutex_trylock(&cc->cards_busy)) { 1365 cs_debug_mask(D_TRACE, "trylock send_emm cards waiting", getprefix()); 1366 cs_sleepms(50); 1367 } 1356 1368 1357 1369 struct cc_card *emm_card = cc->last_emm_card; … … 1459 1471 cl->cc=NULL; 1460 1472 1473 cs_debug_mask(D_TRACE, "exit cccam1/3"); 1461 1474 cc_free_cardlist(cc->cards, TRUE); 1462 1475 ll_destroy_data(cc->pending_emms); … … 1469 1482 pthread_mutex_destroy(&cc->lockcmd); 1470 1483 1484 cs_debug_mask(D_TRACE, "exit cccam2/3"); 1471 1485 if (!pthread_mutex_trylock(&cc->ecm_busy)) 1472 1486 pthread_mutex_unlock(&cc->ecm_busy); … … 1479 1493 add_garbage(cc->prefix); 1480 1494 add_garbage(cc); 1495 1496 cs_debug_mask(D_TRACE, "exit cccam3/3"); 1481 1497 } 1482 1498 … … 1749 1765 1750 1766 if (l == 0x48) { //72 bytes: normal server data 1751 pthread_mutex_lock(&cc->cards_busy); 1767 while (pthread_mutex_trylock(&cc->cards_busy)) { 1768 cs_debug_mask(D_TRACE, "%s trylock MSG_SRV_DATA cards waiting", getprefix()); 1769 cs_sleepms(50); 1770 } 1752 1771 cc_free_cardlist(cc->cards, FALSE); 1753 1772 cc->last_emm_card = NULL; … … 1861 1880 rdr->card_status = CARD_INSERTED; 1862 1881 1863 pthread_mutex_lock(&cc->cards_busy); 1882 while (pthread_mutex_trylock(&cc->cards_busy)) { 1883 cs_debug_mask(D_TRACE, "%s trylock MSG_NEW_CARD cards waiting", getprefix()); 1884 cs_sleepms(50); 1885 } 1864 1886 1865 1887 struct cc_card *card = read_card(data, buf[1]==MSG_NEW_CARD_SIDINFO); … … 1929 1951 1930 1952 case MSG_CARD_REMOVED: { 1931 pthread_mutex_lock(&cc->cards_busy); 1953 while (pthread_mutex_trylock(&cc->cards_busy)) { 1954 cs_debug_mask(D_TRACE, "%s trylock MSG_CARD_REMOVED cards waiting", getprefix()); 1955 cs_sleepms(50); 1956 } 1932 1957 cc_card_removed(cl, b2i(4, buf + 4)); 1933 1958 pthread_mutex_unlock(&cc->cards_busy); … … 1980 2005 return -1; // reader restart needed 1981 2006 1982 pthread_mutex_lock(&cc->cards_busy); 1983 struct cc_extended_ecm_idx *eei = get_extended_ecm_idx(cl, 2007 while (pthread_mutex_trylock(&cc->cards_busy)) { 2008 cs_debug_mask(D_TRACE, "%s trylock MSG_CW_NOK cards waiting", getprefix()); 2009 cs_sleepms(50); 2010 } 2011 2012 struct cc_extended_ecm_idx *eei = get_extended_ecm_idx(cl, 1984 2013 cc->extended_mode ? cc->g_flag : 1, TRUE); 1985 2014 if (!eei) { … … 2133 2162 2134 2163 } else { //READER: 2135 pthread_mutex_lock(&cc->cards_busy); 2136 cc->recv_ecmtask = -1; 2164 while (pthread_mutex_trylock(&cc->cards_busy)) { 2165 cs_debug_mask(D_TRACE, "%s trylock MSG_CW_ECM cards waiting", getprefix()); 2166 cs_sleepms(50); 2167 } 2168 cc->recv_ecmtask = -1; 2137 2169 struct cc_extended_ecm_idx *eei = get_extended_ecm_idx(cl, 2138 2170 cc->extended_mode ? cc->g_flag : 1, TRUE); … … 2831 2863 pthread_setspecific(getclient, cl); 2832 2864 2865 if (cl->ip) 2866 cs_debug_mask(D_CLIENT, "cccam: new connection from %s", cs_inet_ntoa(cl->ip)); 2867 2833 2868 cl->pfd = cl->udp_fd; 2834 2869 int32_t ret; … … 2916 2951 } else { 2917 2952 if (cc->cards) { 2918 pthread_mutex_lock(&cc->cards_busy); 2953 while (pthread_mutex_trylock(&cc->cards_busy)) { 2954 cs_debug_mask(D_TRACE, "%s trylock cc_cli_connect cards waiting", getprefix()); 2955 cs_sleepms(50); 2956 } 2957 2919 2958 LL_ITER *it = ll_iter_create(cc->cards); 2920 2959 struct cc_card *card;
Note:
See TracChangeset
for help on using the changeset viewer.