Changeset 22573


Ignore:
Timestamp:
07/28/13 08:30:04 (11 years ago)
Author:
nit
Message:

[titan] add download/copyfile mem to oldentry if thread hangs

Location:
titan/titan
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/copyfile.h

    r22568 r22573  
    99        off64_t count = 0, len = 0;
    1010        unsigned char* buf = NULL;
    11         time_t akttime = 0;
    1211
    1312        fdfrom = open(from, O_RDONLY);
     
    101100       
    102101end:
    103         akttime = time(NULL);
    104 
    105102        if(fdfrom >= 0)
    106103                close(fdfrom);
     
    125122
    126123        //if the code from end to here takes longer then 8 sek, don't use cnode, cnode is freed after 10 sek
    127         if(cnode != NULL && (time(NULL) - akttime) < 8) cnode->ret = ret;
     124        if(cnode != NULL) cnode->ret = ret;
    128125
    129126        return ret;
     
    271268        }
    272269        ret = cnode->ret;
    273         free(cnode); cnode = NULL;
     270       
     271        if(count < 10)
     272        {
     273                free(cnode);
     274                cnode = NULL;
     275        }
     276        else
     277                addoldentry((void*)dnode, 2, time(NULL) + 7200, NULL);
    274278
    275279        if(fromthread == 1)
  • titan/titan/download.h

    r19884 r22573  
    111111        }
    112112        ret = dnode->ret;
    113         free(dnode); dnode = NULL;
     113       
     114        if(count < 10)
     115        {
     116                free(dnode);
     117                dnode = NULL;
     118        }
     119        else
     120                addoldentry((void*)dnode, 1, time(NULL) + 7200, NULL);
    114121
    115122        if(fromthread == 1)
  • titan/titan/header.h

    r22484 r22573  
    6363
    6464//oldentry.h
     65struct oldentry* addoldentry(void* entry, int type, time_t del, struct oldentry* last);
    6566void deloldentry(struct oldentry *entry, int flag);
    6667
  • titan/titan/oldentry.h

    r18573 r22573  
    44void oldentrythreadfunc(struct stimerthread* self)
    55{
    6         debug(401, "start oldentry thread");
     6        debug(401, "start oldentry thread");
    77
    88        m_lock(&status.oldentrymutex, 18);
     
    1818
    1919        m_unlock(&status.oldentrymutex, 18);
    20         debug(401, "end oldentry thread");
     20        debug(401, "end oldentry thread");
    2121}
    2222
     23//type 0: epg
     24//type 1: download
     25//type 2: copyfile
    2326struct oldentry* addoldentry(void* entry, int type, time_t del, struct oldentry* last)
    2427{
     
    8083
    8184                        if(node->type == 0)
    82                         {
    8385                                deloldentryepg(node->entry);
    84                                 node->entry = NULL;
    85                         }
     86                        else if(node->type == 1)
     87                                free(node->entry);
     88                        else if(node->type == 2)
     89                                free(node->entry);
     90                       
     91                        node->entry = NULL;
    8692
    8793                        free(node);
Note: See TracChangeset for help on using the changeset viewer.