Changeset 11578


Ignore:
Timestamp:
Apr 4, 2020, 9:57:01 PM (2 months ago)
Author:
felixka
Message:
  • rework code ref gbox_maxecmsend
  • fix for ticket #4780
  • change default to 5
  • clean up some ecm stuff
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-gbox-cards.c

    r11573 r11578  
    569569                        {
    570570                            nb_matching_crds++;
    571                             if (time_since_lastcw < GBOX_SID_CONFIRM_TIME && er->gbox_ecm_status == GBOX_ECM_NOT_ASKED)
     571                            if (time_since_lastcw < GBOX_SID_CONFIRM_TIME && er->gbox_ecm_status == GBOX_ECM_NEW_REQ)
    572572                                { enough = 1; }
    573573                        }
  • trunk/module-gbox.c

    r11576 r11578  
    11901190            gbox_remove_all_bad_sids(&proxy->ecmtask[i], proxy->ecmtask[i].srvid);
    11911191
    1192             if(proxy->ecmtask[i].gbox_ecm_status == GBOX_ECM_NOT_ASKED || proxy->ecmtask[i].gbox_ecm_status == GBOX_ECM_ANSWERED)
     1192            if(proxy->ecmtask[i].gbox_ecm_status == GBOX_ECM_NEW_REQ || proxy->ecmtask[i].gbox_ecm_status == GBOX_ECM_ANSWERED)
    11931193            {
    11941194                return -1;
     
    18051805}
    18061806
    1807 /* // see r11270
    1808 void *gbox_rebroadcast_thread(struct gbox_rbc_thread_args *args)
    1809 {
    1810     if (!args) { return NULL; }
    1811 
    1812     struct s_client *cli = args->cli;
    1813     ECM_REQUEST *er = args->er;
    1814     uint32_t waittime = args->waittime;
    1815 
    1816     //NEEDFIX currently the next line avoids a second rebroadcast
    1817     if (!is_valid_client(cli)) { return NULL; }
    1818 
    1819     SAFE_MUTEX_LOCK(&cli->thread_lock);
    1820     cli->thread_active = 1;
    1821     SAFE_SETSPECIFIC(getclient, cli);
    1822     set_thread_name(__func__);
    1823     cli->thread_active = 0;
    1824     SAFE_MUTEX_UNLOCK(&cli->thread_lock);
    1825 
    1826     cs_sleepms(waittime);
    1827     if (!cli || cli->kill || !cli->gbox || !er) { return NULL; }
    1828     SAFE_MUTEX_LOCK(&cli->thread_lock);
    1829     cli->thread_active = 1;
    1830 
    1831     struct gbox_peer *peer = cli->gbox;
    1832 
    1833     struct timeb t_now, tbc;
    1834     cs_ftime(&t_now);
    1835 
    1836     tbc = er->tps;
    1837     add_ms_to_timeb_diff(&tbc, cfg.ctimeout);
    1838     int32_t time_to_timeout = (int32_t) comp_timeb(&tbc, &t_now);
    1839 
    1840     //ecm is not answered yet and still chance to get CW
    1841     if (er->rc >= E_NOTFOUND && time_to_timeout > GBOX_DEFAULT_CW_TIME)
    1842     {
    1843         cs_writelock(__func__, &peer->lock);
    1844         gbox_send_ecm(cli, er);
    1845         cs_writeunlock(__func__, &peer->lock);
    1846     }
    1847     cli->thread_active = 0;
    1848     SAFE_MUTEX_UNLOCK(&cli->thread_lock);
    1849 
    1850     return NULL;
    1851 }
    1852 */
    1853 
    18541807static int32_t gbox_send_ecm(struct s_client *cli, ECM_REQUEST *er)
    18551808{
    1856     if(!cli || !er || !cli->reader)
     1809    if(!cli || !cli->reader || !er || !er->ecmlen)
    18571810    {
    18581811        return -1;
     
    18881841    }
    18891842
    1890     if(er->gbox_ecm_status == GBOX_ECM_NOT_ASKED)
     1843    if(er->gbox_ecm_status == GBOX_ECM_NEW_REQ)
    18911844    {
    18921845        er->gbox_cards_pending = ll_create("pending_gbox_cards");
     
    18951848    uint8_t send_buf[1024];
    18961849    int32_t buflen, len1;
    1897 
    1898     if(!er->ecmlen)
    1899     {
    1900         return 0;
    1901     }
    1902 
     1850   
    19031851    len1 = er->ecmlen + 18; // length till end of ECM
    19041852
     
    19081856
    19091857    uint8_t nb_matching_crds = 0;
    1910     uint8_t max_ecm_reached = 0;
    19111858    uint32_t current_avg_card_time = 0;
    19121859
     
    19481895    nb_matching_crds = gbox_get_cards_for_ecm(&send_buf[0], len1 + 10, cli->reader->gbox_maxecmsend, er, &current_avg_card_time, peer->gbox.id, cli->reader->gbox_force_remm);
    19491896
    1950     if (nb_matching_crds == cli->reader->gbox_maxecmsend)
    1951     {
    1952         max_ecm_reached = 1;
    1953     }
    19541897    buflen += nb_matching_crds * 3;
    19551898
    1956     if(!nb_matching_crds && er->gbox_ecm_status == GBOX_ECM_NOT_ASKED)
     1899    if(!nb_matching_crds && er->gbox_ecm_status == GBOX_ECM_NEW_REQ)
    19571900    {
    19581901        cs_log_dbg(D_READER, "no valid card found for CAID: %04X PROV: %06X", er->caid, er->prid);
     
    19731916            }
    19741917
    1975     //  send_buf[buflen] = er->gbox_ecm_dist +=1;
    1976     //  buflen++;
    1977 
    19781918        memcpy(&send_buf[buflen], gbox_get_my_checkcode(), 7);
    19791919        buflen = buflen + 7;
     
    20061946            cs_log_dbg(D_READER, "Pending Card ID: %04X Slot: %02X time: %d", pending->id.peer, pending->id.slot, pending->pending_time);
    20071947            er->gbox_cw_src_peer = pending->id.peer;
     1948            cs_log_dbg(D_READER,"<- ECM (<-%d) - caid: %04X prov: %06X sid: %04X to cw-src-peer: %04X - ecm_src_peer: %04X",
     1949                gbox_get_crd_dist_lev(er->gbox_cw_src_peer) & 0xf, er->caid, er->prid, er->srvid, er->gbox_cw_src_peer, er->gbox_ecm_src_peer);
    20081950        }
    20091951        ll_li_destroy(li);
    20101952
    2011         if(er->gbox_ecm_status > GBOX_ECM_NOT_ASKED)
     1953        if(er->gbox_ecm_status == GBOX_ECM_NEW_REQ)
    20121954        {
    20131955            er->gbox_ecm_status++;
    2014         }
    2015         else
    2016         {
    2017             if(max_ecm_reached)
    2018             {
    2019                 er->gbox_ecm_status = GBOX_ECM_SENT;
    2020             }
    2021             else
    2022             {
    2023                 er->gbox_ecm_status = GBOX_ECM_SENT_ALL;
    2024             }
    20251956            cli->pending++;
    20261957        }
    2027 
    2028       cs_log_dbg(D_READER,"<- ECM (<-%d) - caid: %04X prov: %06X sid: %04X to %d card(s) of cw-src-peer: %04X - ecm_src_peer: %04X",
    2029             gbox_get_crd_dist_lev(er->gbox_cw_src_peer) & 0xf, er->caid, er->prid, er->srvid, nb_matching_crds, er->gbox_cw_src_peer, er->gbox_ecm_src_peer);
    20301958
    20311959        gbox_send(cli, send_buf, buflen);
    20321960        cli->reader->last_s = time((time_t *) 0);
    2033 
    2034 /*  // see r11270
    2035         if(er->gbox_ecm_status < GBOX_ECM_ANSWERED)
    2036         {
    2037             //Create thread to rebroacast ecm after time
    2038             struct gbox_rbc_thread_args args;
    2039             args.cli = cli;
    2040             args.er = er;
    2041             if ((current_avg_card_time > 0) && (cont_card_1 == 1))
    2042             {
    2043                 args.waittime = current_avg_card_time + (current_avg_card_time / 2);
    2044                 if (args.waittime < GBOX_MIN_REBROADCAST_TIME)
    2045                 { args.waittime = GBOX_MIN_REBROADCAST_TIME; }
    2046             }
    2047             else
    2048                 { args.waittime = GBOX_REBROADCAST_TIMEOUT; }
    2049             cs_log_dbg(D_READER, "Creating rebroadcast thread with waittime: %d", args.waittime);
    2050             int32_t ret = start_thread("rebroadcast", (void *)gbox_rebroadcast_thread, &args, NULL, 1, 1);
    2051             if(ret)
    2052             {
    2053                 return -1;
    2054             }
    2055         }
    2056         else
    2057 */      { er->gbox_ecm_status--; }
    20581961    }
    20591962    return 0;
  • trunk/module-gbox.h

    r11576 r11578  
    77#define GBOX_MAXHOPS                 5
    88#define DEFAULT_GBOX_MAX_DIST        2
    9 #define DEFAULT_GBOX_MAX_ECM_SEND    3
     9#define DEFAULT_GBOX_MAX_ECM_SEND    5
    1010#define DEFAULT_GBOX_RESHARE         2
    1111#define DEFAULT_CCC_GBOX_RESHARE     1
     
    1414#define GBOX_MAX_RECONNECT         300
    1515#define CS_GBOX_MAX_LOCAL_CARDS     16
    16 #define GBOX_REBROADCAST_TIMEOUT  1250
    17 #define GBOX_MIN_REBROADCAST_TIME  100
    1816#define GBOX_SID_CONFIRM_TIME     3600
    1917#define GBOX_DEFAULT_CW_TIME       500
     
    2220#define MIN_ECM_LENGTH               8
    2321#define STATS_WRITE_TIME           300 // write stats file every 5 min
    24 #define MAX_GBOX_CARDS            1024 // send max. 1024 to peer
     22#define MAX_GBOX_CARDS            1024 // send max. 1024 cards to peer
    2523#define LOCAL_GBOX_MAJOR_VERSION  0x02
    2624
     
    3533#define MSG_HERE      0xA0A1
    3634
    37 #define GBOX_ECM_NOT_ASKED      0
     35#define GBOX_ECM_NEW_REQ        0
    3836#define GBOX_ECM_SENT           1
    39 #define GBOX_ECM_SENT_ALL       2
    40 #define GBOX_ECM_SENT_ALL_TWICE 3
    41 #define GBOX_ECM_ANSWERED       4
     37#define GBOX_ECM_ANSWERED       2
    4238
    4339#define GBOX_CARD_TYPE_GBOX  0
Note: See TracChangeset for help on using the changeset viewer.