Changeset 5304 for trunk/module-cccam.c
- Timestamp:
- 05/28/11 01:47:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r5292 r5304 460 460 return -1; 461 461 462 while (cl->cc && cc->mode != CCCAM_MODE_SHUTDOWN && pthread_mutex_trylock(&cc->lockcmd)) {462 while (cl->cc && cc->mode != CCCAM_MODE_SHUTDOWN && cs_trylock(&cc->lockcmd)) { 463 463 cs_debug_mask(D_TRACE, "%s trylock recv waiting", getprefix()); 464 464 cs_sleepms(50); … … 475 475 else 476 476 cs_debug_mask(cl->typ=='c'?D_CLIENT:D_READER, "%s invalid header length (expected 4, read %d)", getprefix(), len); 477 pthread_mutex_unlock(&cc->lockcmd);477 cs_unlock(&cc->lockcmd); 478 478 return -1; 479 479 } … … 487 487 if (size) { // check if any data is expected in msg 488 488 if (size > maxlen) { 489 pthread_mutex_unlock(&cc->lockcmd);489 cs_unlock(&cc->lockcmd); 490 490 cs_debug_mask(cl->typ=='c'?D_CLIENT:D_READER, "%s message too big (size=%d max=%d)", getprefix(), size, maxlen); 491 491 return 0; … … 497 497 498 498 if (len != size) { 499 pthread_mutex_unlock(&cc->lockcmd);499 cs_unlock(&cc->lockcmd); 500 500 if (len <= 0) 501 501 cs_debug_mask(cl->typ=='c'?D_CLIENT:D_READER, "%s disconnected by remote", getprefix()); … … 510 510 } 511 511 512 pthread_mutex_unlock(&cc->lockcmd);512 cs_unlock(&cc->lockcmd); 513 513 514 514 //cs_ddump_mask(cl->typ=='c'?D_CLIENT:D_READER, buf, len, "cccam: full decrypted msg, len=%d:", len); … … 531 531 struct cc_data *cc = cl->cc; 532 532 533 while (cl->cc && cc->mode != CCCAM_MODE_SHUTDOWN && pthread_mutex_trylock(&cc->lockcmd)) { //We need this because cc_cmd_send is called from cccshare533 while (cl->cc && cc->mode != CCCAM_MODE_SHUTDOWN && cs_trylock(&cc->lockcmd)) { //We need this because cc_cmd_send is called from cccshare 534 534 cs_debug_mask(D_TRACE, "%s trylock send waiting", getprefix()); 535 535 cs_sleepms(50); … … 557 557 rdr->last_s = time(NULL); 558 558 559 pthread_mutex_unlock(&cc->lockcmd);559 cs_unlock(&cc->lockcmd); 560 560 561 561 free(netbuf); … … 1056 1056 //Without extended mode, only one ecm at a time could be send 1057 1057 //this is a limitation of "O" CCCam 1058 if ( pthread_mutex_trylock(&cc->ecm_busy) == EBUSY) { //Unlock by NOK or ECM ACK1058 if (cs_trylock(&cc->ecm_busy) == EBUSY) { //Unlock by NOK or ECM ACK 1059 1059 cs_debug_mask(D_READER, 1060 1060 "%s ecm trylock: ecm busy, retrying later after msg-receive", … … 1088 1088 if (!cc->extended_mode) { 1089 1089 rdr->available = 1; 1090 pthread_mutex_unlock(&cc->ecm_busy);1090 cs_unlock(&cc->ecm_busy); 1091 1091 } 1092 1092 cs_debug_mask(D_READER, "%s no ecm pending!", getprefix()); … … 1106 1106 cur_srvid.ecmlen = cur_er->l; 1107 1107 1108 while ( pthread_mutex_trylock(&cc->cards_busy)) {1108 while (cs_trylock(&cc->cards_busy)) { 1109 1109 cs_debug_mask(D_TRACE, "%s trylock send_ecm cards waiting", getprefix()); 1110 1110 cs_sleepms(50); … … 1211 1211 //For EMM 1212 1212 set_au_data(cl, rdr, card, cur_er); 1213 pthread_mutex_unlock(&cc->cards_busy);1213 cs_unlock(&cc->cards_busy); 1214 1214 1215 1215 if (cc->extended_mode) … … 1245 1245 } 1246 1246 } 1247 pthread_mutex_unlock(&cc->cards_busy);1247 cs_unlock(&cc->cards_busy); 1248 1248 1249 1249 //process next pending ecm! … … 1252 1252 if (!cc->extended_mode) { 1253 1253 rdr->available = 1; 1254 pthread_mutex_unlock(&cc->ecm_busy);1254 cs_unlock(&cc->ecm_busy); 1255 1255 } 1256 1256 … … 1294 1294 if ((emmbuf = ll_iter_next(&it))) { 1295 1295 if (!cc->extended_mode) { 1296 if ( pthread_mutex_trylock(&cc->ecm_busy) == EBUSY) { //Unlock by NOK or ECM ACK1296 if (cs_trylock(&cc->ecm_busy) == EBUSY) { //Unlock by NOK or ECM ACK 1297 1297 return 0; //send later with cc_send_ecm 1298 1298 } … … 1358 1358 1359 1359 //Last used card is first card of current_cards: 1360 while ( pthread_mutex_trylock(&cc->cards_busy)) {1360 while (cs_trylock(&cc->cards_busy)) { 1361 1361 cs_debug_mask(D_TRACE, "trylock send_emm cards waiting", getprefix()); 1362 1362 cs_sleepms(50); … … 1381 1381 cs_debug_mask(D_EMM, "%s emm for client %8X not possible, no card found!", 1382 1382 getprefix(), ep->client->thread); 1383 pthread_mutex_unlock(&cc->cards_busy);1383 cs_unlock(&cc->cards_busy); 1384 1384 return 0; 1385 1385 } … … 1408 1408 memcpy(emmbuf + 12, ep->emm, ep->l); 1409 1409 1410 pthread_mutex_unlock(&cc->cards_busy);1410 cs_unlock(&cc->cards_busy); 1411 1411 1412 1412 ll_append(cc->pending_emms, emmbuf); … … 1468 1468 cl->cc=NULL; 1469 1469 1470 while ( pthread_mutex_trylock(&cc->lockcmd)) cs_sleepms(110);1471 pthread_mutex_trylock(&cc->ecm_busy);1472 pthread_mutex_trylock(&cc->cards_busy);1470 while (cs_trylock(&cc->lockcmd)) cs_sleepms(110); 1471 cs_lock(&cc->ecm_busy); 1472 cs_lock(&cc->cards_busy); 1473 1473 1474 1474 cs_debug_mask(D_TRACE, "exit cccam1/3"); … … 1479 1479 ll_destroy_data(cc->extended_ecm_idx); 1480 1480 1481 pthread_mutex_unlock(&cc->lockcmd);1481 cs_unlock(&cc->lockcmd); 1482 1482 pthread_mutex_destroy(&cc->lockcmd); 1483 1483 1484 1484 cs_debug_mask(D_TRACE, "exit cccam2/3"); 1485 pthread_mutex_unlock(&cc->ecm_busy);1485 cs_unlock(&cc->ecm_busy); 1486 1486 pthread_mutex_destroy(&cc->ecm_busy); 1487 1487 1488 pthread_mutex_unlock(&cc->cards_busy);1488 cs_unlock(&cc->cards_busy); 1489 1489 pthread_mutex_destroy(&cc->cards_busy); 1490 1490 … … 1767 1767 1768 1768 if (l == 0x48) { //72 bytes: normal server data 1769 while ( pthread_mutex_trylock(&cc->cards_busy)) {1769 while (cs_trylock(&cc->cards_busy)) { 1770 1770 cs_debug_mask(D_TRACE, "%s trylock MSG_SRV_DATA cards waiting", getprefix()); 1771 1771 cs_sleepms(50); … … 1781 1781 cc->num_reshare2 = 0; 1782 1782 cc->num_resharex = 0; 1783 pthread_mutex_unlock(&cc->cards_busy);1783 cs_unlock(&cc->cards_busy); 1784 1784 1785 1785 memcpy(cc->peer_node_id, data, 8); … … 1884 1884 rdr->card_status = CARD_INSERTED; 1885 1885 1886 while ( pthread_mutex_trylock(&cc->cards_busy)) {1886 while (cs_trylock(&cc->cards_busy)) { 1887 1887 cs_debug_mask(D_TRACE, "%s trylock MSG_NEW_CARD cards waiting", getprefix()); 1888 1888 cs_sleepms(50); … … 1947 1947 } 1948 1948 1949 pthread_mutex_unlock(&cc->cards_busy);1949 cs_unlock(&cc->cards_busy); 1950 1950 1951 1951 break; … … 1953 1953 1954 1954 case MSG_CARD_REMOVED: { 1955 while ( pthread_mutex_trylock(&cc->cards_busy)) {1955 while (cs_trylock(&cc->cards_busy)) { 1956 1956 cs_debug_mask(D_TRACE, "%s trylock MSG_CARD_REMOVED cards waiting", getprefix()); 1957 1957 cs_sleepms(50); 1958 1958 } 1959 1959 cc_card_removed(cl, b2i(4, buf + 4)); 1960 pthread_mutex_unlock(&cc->cards_busy);1960 cs_unlock(&cc->cards_busy); 1961 1961 break; 1962 1962 } … … 2008 2008 return -1; // reader restart needed 2009 2009 2010 while ( pthread_mutex_trylock(&cc->cards_busy)) {2010 while (cs_trylock(&cc->cards_busy)) { 2011 2011 cs_debug_mask(D_TRACE, "%s trylock MSG_CW_NOK cards waiting", getprefix()); 2012 2012 cs_sleepms(50); … … 2064 2064 } 2065 2065 cc->cmd05NOK = 0; 2066 pthread_mutex_unlock(&cc->cards_busy);2066 cs_unlock(&cc->cards_busy); 2067 2067 2068 2068 if (!cc->extended_mode) { 2069 2069 rdr->available = 1; 2070 pthread_mutex_unlock(&cc->ecm_busy);2070 cs_unlock(&cc->ecm_busy); 2071 2071 } 2072 2072 … … 2163 2163 2164 2164 } else { //READER: 2165 while ( pthread_mutex_trylock(&cc->cards_busy)) {2165 while (cs_trylock(&cc->cards_busy)) { 2166 2166 cs_debug_mask(D_TRACE, "%s trylock MSG_CW_ECM cards waiting", getprefix()); 2167 2167 cs_sleepms(50); … … 2222 2222 } 2223 2223 } 2224 pthread_mutex_unlock(&cc->cards_busy);2224 cs_unlock(&cc->cards_busy); 2225 2225 2226 2226 if (!cc->extended_mode) { 2227 2227 rdr->available = 1; 2228 pthread_mutex_unlock(&cc->ecm_busy);2228 cs_unlock(&cc->ecm_busy); 2229 2229 } 2230 2230 … … 2435 2435 if (!cc->extended_mode) { 2436 2436 rdr->available = 1; 2437 pthread_mutex_unlock(&cc->ecm_busy);2437 cs_unlock(&cc->ecm_busy); 2438 2438 } 2439 2439 cc_send_ecm(cl, NULL, NULL); … … 2909 2909 } else { 2910 2910 if (cc->cards) { 2911 while ( pthread_mutex_trylock(&cc->cards_busy)) {2911 while (cs_trylock(&cc->cards_busy)) { 2912 2912 cs_debug_mask(D_TRACE, "%s trylock cc_cli_connect cards waiting", getprefix()); 2913 2913 cs_sleepms(50); … … 2915 2915 2916 2916 cc_free_cardlist(cc->cards, FALSE); 2917 pthread_mutex_unlock(&cc->cards_busy);2917 cs_unlock(&cc->cards_busy); 2918 2918 } 2919 2919 if (cc->extended_ecm_idx) 2920 2920 free_extended_ecm_idx(cc); 2921 2921 2922 pthread_mutex_trylock(&cc->ecm_busy);2923 pthread_mutex_unlock(&cc->ecm_busy);2922 cs_trylock(&cc->ecm_busy); 2923 cs_unlock(&cc->ecm_busy); 2924 2924 } 2925 2925 if (!cc->prefix)
Note:
See TracChangeset
for help on using the changeset viewer.