Overview
Comment: | Updated to keep track of sent bytes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5d3ae251283298fdc0f9b29999ecd86b |
User & Date: | rkeene on 2014-02-06 06:47:32 |
Other Links: | manifest | tags |
Context
2014-02-06
| ||
07:42 | Updated to correctly encode range check-in: 6add2b1206 user: rkeene tags: trunk | |
06:47 | Updated to keep track of sent bytes check-in: 5d3ae25128 user: rkeene tags: trunk | |
06:02 | Updated to ignore SIGPIPE and made several Range handling improvements check-in: f27754658d user: rkeene tags: trunk | |
Changes
Modified filed.c from [5e37a15236] to [b68d97d7c3].
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 | off_t offset; /*** Range start ***/ ssize_t length; /*** Range length ***/ } range; } headers; }; /* Global variables */ struct filed_fileinfo *filed_fileinfo_fdcache; unsigned int filed_fileinfo_fdcache_size = CACHE_SIZE; /* Initialize process */ static int filed_init(void) { unsigned int idx; int mutex_init_ret; | > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | off_t offset; /*** Range start ***/ ssize_t length; /*** Range length ***/ } range; } headers; }; /* Global variables */ /** Open File cache **/ struct filed_fileinfo *filed_fileinfo_fdcache; unsigned int filed_fileinfo_fdcache_size = CACHE_SIZE; /* Initialize process */ static int filed_init(void) { unsigned int idx; int mutex_init_ret; |
︙ | ︙ | |||
376 377 378 379 380 381 382 | ); } /* Handle a single request from a client */ static void filed_handle_client(int fd, struct filed_http_request *request) { struct filed_fileinfo *fileinfo; ssize_t sendfile_ret; | | < < | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | ); } /* Handle a single request from a client */ static void filed_handle_client(int fd, struct filed_http_request *request) { struct filed_fileinfo *fileinfo; ssize_t sendfile_ret; size_t sendfile_len, sendfile_sent; off_t sendfile_offset; char *path; char *date_current, date_current_b[64]; int http_code; FILE *fp; /* Determine current time */ date_current = filed_format_time(date_current_b, sizeof(date_current_b), time(NULL)); /* Open socket as ANSI I/O for ease of use */ fp = fdopen(fd, "w+b"); if (fp == NULL) { close(fd); return; } request = filed_get_http_request(fp, request); path = request->path; filed_log_msg("PROCESS_REPLY_START FD=... PATH=... RANGE_START=... RANGE_LENGTH=..."); if (path == NULL) { filed_error_page(fp, date_current, 500); |
︙ | ︙ | |||
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | filed_log_msg("PROCESS_REPLY_COMPLETE FD=... STATUS=20X"); filed_log_msg("SEND_START IFD=... OFD=... BYTES=..."); sendfile_offset = request->headers.range.offset; sendfile_len = request->headers.range.length; while (1) { sendfile_ret = sendfile(fd, fileinfo->fd, &sendfile_offset, sendfile_len); if (sendfile_ret <= 0) { break; } sendfile_len -= sendfile_ret; if (sendfile_len == 0) { break; } } filed_log_msg("SEND_COMPLETE STATUS=... IFD=... OFD=... BYTES=... BYTES_SENT=..."); } | > > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | filed_log_msg("PROCESS_REPLY_COMPLETE FD=... STATUS=20X"); filed_log_msg("SEND_START IFD=... OFD=... BYTES=..."); sendfile_offset = request->headers.range.offset; sendfile_len = request->headers.range.length; sendfile_sent = 0; while (1) { sendfile_ret = sendfile(fd, fileinfo->fd, &sendfile_offset, sendfile_len); if (sendfile_ret <= 0) { break; } sendfile_len -= sendfile_ret; sendfile_sent += sendfile_ret; if (sendfile_len == 0) { break; } } filed_log_msg("SEND_COMPLETE STATUS=... IFD=... OFD=... BYTES=... BYTES_SENT=..."); } |
︙ | ︙ |