Changeset 959 for branches/monitor-improvement/module-cccam.c
- Timestamp:
- 12/26/09 22:54:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/module-cccam.c
r885 r959 337 337 if (errno != EINPROGRESS) { 338 338 cs_debug("cccam: conn_nb 3 (fd=%d)", sockfd); 339 //return(-1);339 //return(-1); 340 340 } 341 341 } … … 512 512 int n, i; 513 513 time_t t; 514 struct cc_data *cc = reader[ridx].cc;514 // struct cc_data *cc = reader[ridx].cc; 515 515 516 516 t=time((time_t *)0); … … 525 525 if (ecmtask[i].rc >= 10) { // stil active and waiting 526 526 // search for the ecm with the lowest time, this should be the next to go 527 if ((!n || ecmtask[n].tps.time-ecmtask[i].tps.time < 0) && &ecmtask[n] != cc->found) n = i;527 if ((!n || ecmtask[n].tps.time-ecmtask[i].tps.time < 0) && &ecmtask[n]) n = i; 528 528 } 529 529 } … … 539 539 ECM_REQUEST *cur_er; 540 540 541 if (!cc) return 0; 542 541 if (!cc || (pfd < 1)) { 542 if (er) { 543 er->rc = 0; 544 er->rcEx = 0x27; 545 cs_log("cccam: server not init!"); 546 write_ecm_answer(fd_c2m, er); 547 } 548 return 0; 549 } 550 551 // pthread_mutex_lock(&cc->ecm_busy); 543 552 if (pthread_mutex_trylock(&cc->ecm_busy) == EBUSY) { 544 553 cs_debug("cccam: ecm trylock: failed to get lock"); … … 566 575 return 0; // ecm already sent 567 576 } 577 578 //cc->found = cur_er; 568 579 569 580 if (buf) memcpy(buf, cur_er->ecm, cur_er->l); … … 646 657 while (card) { 647 658 if (card->caid == cur_er->caid) { // caid matches 648 649 659 LLIST_ITR sitr; 650 660 uint16 *sid = llist_itr_init(card->badsids, &sitr); 651 661 while (sid) { 652 if (*sid == cur_er->srvid) sid = llist_itr_remove(&sitr); 662 if (*sid == cur_er->srvid) 663 sid = llist_itr_remove(&sitr); 653 664 else sid = llist_itr_next(&sitr); 654 665 } … … 658 669 } 659 670 llist_itr_release(&itr); 660 } 661 662 pthread_mutex_unlock(&cc->lock); 671 672 pthread_mutex_unlock(&cc->ecm_busy); 673 } 674 663 675 return 0; 664 676 } 665 666 // this is a hack and it's baaaaaad. It's also not used yet!667 677 /* 668 static void cc_rebuild_caid_tab()669 {670 int zz;671 for(zz = 0; zz < CS_MAXCAIDTAB; zz++) {672 cs_log("caid %x", reader[ridx].ctab.caid[zz]);673 }674 }675 */676 677 678 static int cc_abort_user_ecms(){ 678 679 int n, i; … … 699 700 700 701 } 701 702 */ 702 703 static cc_msg_type_t cc_parse_msg(uint8 *buf, int l) 703 704 { 704 705 int ret = buf[1]; 705 706 struct cc_data *cc = reader[ridx].cc; 706 707 pthread_mutex_lock(&cc->lock);708 707 709 708 switch (buf[1]) { … … 716 715 break; 717 716 case MSG_NEW_CARD: 718 // find blank caid slot in tab and add caid719 717 { 720 718 int i = 0; 721 /*, p = 0;722 while(reader[ridx].ctab.caid[i]) {723 if (reader[ridx].ctab.caid[i] == b2i(2, buf+12)) p = 1;724 i++;725 }726 if (!p) {727 reader[ridx].ctab.caid[i] = b2i(2, buf+12);728 }729 */730 731 // if (b2i(2, buf+12) == reader[ridx].ctab.caid[0]) { // only add cards with relevant caid (for now)732 // int i;733 719 struct cc_card *card = malloc(sizeof(struct cc_card)); 734 720 … … 826 812 } 827 813 828 pthread_mutex_unlock(&cc->lock);829 814 return ret; 830 815 } … … 851 836 { 852 837 int n; 838 struct cc_data *cc = reader[ridx].cc; 853 839 uchar *cbuf = malloc(l); 854 840 855 841 memcpy(cbuf, buf, l); // make a copy of buf 842 843 pthread_mutex_lock(&cc->lock); 856 844 857 845 if (!is_server) { … … 879 867 X_FREE(cbuf); 880 868 869 pthread_mutex_unlock(&cc->lock); 870 881 871 return(n); 882 872 } … … 964 954 pfd=client[cs_idx].udp_fd; 965 955 966 if (cc_send_cli_data( cc)<=0) {956 if (cc_send_cli_data()<=0) { 967 957 cs_log("cccam: login failed, could not send client data"); 968 958 return -3;
Note:
See TracChangeset
for help on using the changeset viewer.