Ticket #6: fix.patch

File fix.patch, 2.2 KB (added by stoecker, 13 years ago)

Fix the issue hopefully correctly

  • ntripcastertypes.h

     
    228228        char buf[20]; // to store hex length. ajd
    229229        int off; // store offset in buf.
    230230        int left;
     231        int finish;
    231232} http_chunk_t;
    232233
    233234typedef struct statistics_St
  • source.c

     
    647647                                                xa_debug (5, "add_chunk: hex [%s], read=%d", con->http_chunk->buf, len);
    648648
    649649                                                if (len > (20 - con->http_chunk->off)) { // a whole line could be read. ajd
    650                                                         con->http_chunk->left = strtol(con->http_chunk->buf, (char **)NULL, 16);
    651                                                         con->http_chunk->off = 0;
    652 
    653                                                         xa_debug (4, "add_chunk: http chunk left=%d", con->http_chunk->left);
    654 
     650                                                        if(con->http_chunk->finish)
     651                                                        {
     652                                                                xa_debug (4, "read trailing [%s]", con->http_chunk->buf);
     653                                                                con->http_chunk->finish = 0;
     654                                                                continue;
     655                                                        }
     656                                                        else
     657                                                        {
     658                                                                con->http_chunk->left = strtol(con->http_chunk->buf, (char **)NULL, 16);
     659                                                                con->http_chunk->off = 0;
     660                                                                con->http_chunk->finish = 1;
     661                                                                xa_debug (4, "add_chunk: http chunk left=%d", con->http_chunk->left);
     662                                                        }
    655663                                                } else if (len > 0) {
    656664                                                        con->http_chunk->off += len;
    657665                                                        len = -1;
     
    761769        con->food.source->chunk[con->food.source->cid].len = read_bytes;
    762770        con->food.source->chunk[con->food.source->cid].clients_left = con->food.source->num_clients;
    763771        con->food.source->cid = (con->food.source->cid + 1) % CHUNKLEN;
    764 
    765 //printf("chunk %d of size %d added!\r\n", con->food.source->cid, read_bytes);
    766 
    767         /* rtsp. ajd */
     772       
    768773        if (con->trans_encoding == chunked_e) {
    769774                con->http_chunk->left = con->http_chunk->left - read_bytes;
    770                 if (con->http_chunk->left <= 0) {
    771                         len = sock_read_line(con->sock, con->http_chunk->buf, 20); // read trailing /n. ajd
    772 
    773                         xa_debug (4, "read trailing [%s]", con->http_chunk->buf);
    774 
    775                         con->http_chunk->off = 0;
    776                 }
    777775                xa_debug (4, "http_chunk left now=%d ", con->http_chunk->left );
    778776        }
    779777}