Changeset 19570


Ignore:
Timestamp:
01/12/13 13:58:05 (11 years ago)
Author:
nit
Message:

[titan] fix tithek thread download

Location:
titan/plugins/tithek
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/tithek/tithek.c

    r19554 r19570  
    5353
    5454        status.hangtime = 99999;
     55        tithekdownloadrun = 0;
     56        tithekdownloadcount = 0;
     57        tithekrun = 1;
    5558        screentithekplay("http://atemio.dyndns.tv/mediathek/mainmenu.list", "Tithek - Mainmenu", 1);
     59        tithekrun = 0;
    5660        status.hangtime = getconfigint("hangtime", NULL);
    5761}
  • titan/plugins/tithek/tithek.h

    r19568 r19570  
    33
    44#define TITHEKPATH "/tmp/tithek"
     5int tithekdownloadrun = 0;
     6int tithekdownloadcount = 0;
     7int tithekrun = 0;
    58
    69//flag 0        - menu
     
    644647void tithekdownloadthread(struct stimerthread* timernode, struct download* node, int flag)
    645648{
     649        tithekdownloadcount++;
    646650        if(node != NULL)
    647651        {
    648652                gethttp(node->host, node->page, node->port, node->filename, node->auth, NULL, 0);
     653
     654                if(tithekrun == 0) unlink(node->filename);
     655
    649656                free(node->host); node->host = NULL;
    650657                free(node->page); node->page = NULL;
     
    654661
    655662        free(node); node = NULL;
     663        tithekdownloadcount--;
     664        tithekdownloadrun = 1;
    656665}
    657666
     
    699708                        if(pic == 1)
    700709                        {
    701                                 //dnode is freed in thread
    702                                 struct download* dnode = calloc(1, sizeof(struct download));
    703                                 if(dnode != NULL)
     710                                if(tithekdownloadcount > 100) //start max 100 threads
     711                                        gethttp(ip, path, 80, localfile, pw, NULL, 0);
     712                                else
    704713                                {
    705                                         dnode->host = ostrcat(ip, NULL, 0, 0);
    706                                         dnode->page = ostrcat(path, NULL, 0, 0);
    707                                         dnode->port = 80;
    708                                         dnode->filename = ostrcat(localfile, NULL, 0, 0);
    709                                         dnode->auth = ostrcat(pw, NULL, 0, 0);
    710                                         dnode->connfd = -1;
    711                                         dnode->ret = -1;
    712                                         addtimer(&tithekdownloadthread, START, 100, 1, (void*)dnode, NULL, NULL);
    713                                         //gethttp(ip, path, 80, localfile, pw, NULL, 0);
     714                                        //dnode is freed in thread
     715                                        struct download* dnode = calloc(1, sizeof(struct download));
     716                                        if(dnode != NULL)
     717                                        {
     718                                                dnode->host = ostrcat(ip, NULL, 0, 0);
     719                                                dnode->page = ostrcat(path, NULL, 0, 0);
     720                                                dnode->port = 80;
     721                                                dnode->filename = ostrcat(localfile, NULL, 0, 0);
     722                                                dnode->auth = ostrcat(pw, NULL, 0, 0);
     723                                                dnode->connfd = -1;
     724                                                dnode->ret = -1;
     725                                                addtimer(&tithekdownloadthread, START, 100, 1, (void*)dnode, NULL, NULL);
     726                                        }
    714727                                }
    715728                        }
     
    11271140                if(count > 500)
    11281141                        delallfiles(TITHEKPATH, ".jpg");
    1129                
    1130                 rcret = waitrc(grid, 0, 0);
     1142
     1143waitrcstart:
     1144                rcret = waitrc(grid, 2000, 0);
     1145
     1146                if(rcret == RCTIMEOUT)
     1147                {
     1148                        if(tithekdownloadrun == 1)
     1149                        {
     1150                                tithekdownloadrun = 0;
     1151                                drawscreen(grid, 0, 0);
     1152                        }
     1153                        goto waitrcstart;
     1154                }
    11311155
    11321156                if(rcret == getrcconfigint("rcexit", NULL)) break;
Note: See TracChangeset for help on using the changeset viewer.