Changeset 4014


Ignore:
Timestamp:
11/29/10 10:35:32 (10 years ago)
Author:
_network
Message:

next try fixing wrong timeout with betatunnel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oscam.c

    r4011 r4014  
    418418    }
    419419    pthread_mutex_unlock(&cwcache_lock);
    420   //decrease ecmache
     420
     421    //decrease ecmache
     422    pthread_mutex_lock(&ecmcache_lock);
    421423    if (ecmcache->next != NULL) { //keep it at least on one entry big
    422424        for (ecmc=ecmcache; ecmc->next->next ; ecmc=ecmc->next) ; //find last element
     
    425427        NULLFREE(ecmc->next); //free last element
    426428    }
     429    pthread_mutex_unlock(&ecmcache_lock);
    427430}
    428431
     
    634637
    635638        //increase ecmcache
     639        pthread_mutex_lock(&ecmcache_lock);
    636640        for (ecmc=ecmcache; ecmc->next ; ecmc=ecmc->next); //ends on last ecmcache entry
    637641        ecmc->next = malloc(sizeof(struct s_ecm));
    638642        if (ecmc->next)
    639643            memset(ecmc->next, 0, sizeof(struct s_ecm));
     644        pthread_mutex_unlock(&ecmcache_lock);
    640645    } else {
    641646        cs_log("max connections reached -> reject client %s", cs_inet_ntoa(ip));
     
    11971202}
    11981203
    1199 static void store_ecm(ECM_REQUEST *er, uint64 grp)
    1200 {
     1204/**
     1205 * ecm cache
     1206 **/
     1207static int check_and_store_ecmcache(ECM_REQUEST *er, uint64 grp)
     1208{
     1209    struct s_ecm *ecmc;
     1210    pthread_mutex_lock(&ecmcache_lock);
     1211    for (ecmc=ecmcache; ecmc ; ecmc=ecmc->next) {
     1212        if ((grp & ecmc->grp) &&
     1213             ecmc->caid==er->caid &&
     1214             (!memcmp(ecmc->ecmd5, er->ecmd5, CS_ECMSTORESIZE)))
     1215        {
     1216            er->rc = 99;
     1217            pthread_mutex_unlock(&ecmcache_lock);
     1218            return(1);
     1219        }
     1220    }
     1221    //store_ecm(er, grp); //Only ECM, no CW!
    12011222    if (ecmidx->next)
    12021223        ecmidx=ecmidx->next;
     
    12071228    ecmidx->grp = grp;
    12081229    ecmidx->reader = er->selected_reader;
    1209 }
    1210 
    1211 /**
    1212  * ecm cache
    1213  **/
    1214 static int check_and_store_ecmcache(ECM_REQUEST *er, uint64 grp)
    1215 {
    1216     struct s_ecm *ecmc;
    1217         pthread_mutex_lock(&ecmcache_lock);
    1218     for (ecmc=ecmcache; ecmc ; ecmc=ecmc->next)
    1219         if ((grp & ecmc->grp) &&
    1220              ecmc->caid==er->caid &&
    1221              (!memcmp(ecmc->ecmd5, er->ecmd5, CS_ECMSTORESIZE)))
    1222         {
    1223                 er->rc = 99;
    1224                 pthread_mutex_unlock(&ecmcache_lock);
    1225             return(1);
    1226         }
    1227         store_ecm(er, grp); //Only ECM, no CW!
    1228         pthread_mutex_unlock(&ecmcache_lock);
     1230
     1231    pthread_mutex_unlock(&ecmcache_lock);
    12291232    return(0);
    12301233}
     
    12521255            continue;
    12531256
    1254         cs_debug_mask(D_TRACE, "cache: ecm %04X found: caid=%04X grp=%lld cgrp=%lld", lc, ecmc->caid, grp, ecmc->grp);
     1257        cs_debug_mask(D_TRACE, "cache: ecm %04X found: ccaid=%04X caid=%04X grp=%lld cgrp=%lld count=%d", lc, er->caid, ecmc->caid, grp, ecmc->grp, count);
    12551258
    12561259        if (!(grp & ecmc->grp))
     
    12601263            continue;
    12611264       
    1262         cs_debug_mask(D_TRACE, "cache: found count=%d", count);
    12631265        memcpy(er->cw, ecmc->cw, 16);
    12641266        er->selected_reader = ecmc->reader;
     
    15031505      for (i=0; i<n; i++) {
    15041506        ecm = &cl->ecmtask[i];
    1505         if (ecm->rc == 99 && ecm->ocaid==er->ocaid && memcmp(ecm->ecmd5, er->ecmd5, CS_ECMSTORESIZE)==0) {
     1507        if (ecm->rc == 99 && ecm->caid==er->caid && memcmp(ecm->ecmd5, er->ecmd5, CS_ECMSTORESIZE)==0) {
    15061508          er->cpti = ecm->cpti;
    15071509          //cs_log("distribute %04X:%06X:%04X cpti %d to client %s", ecm->caid, ecm->prid, ecm->srvid, ecm->cpti, username(cl));
Note: See TracChangeset for help on using the changeset viewer.