Overview
Comment: | Added support for a non-blocking HTTP mode |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
145eda8451544dab73014d8bda5a2cde |
User & Date: | rkeene on 2014-02-06 07:50:04 |
Other Links: | manifest | tags |
Context
2014-02-06
| ||
07:53 | Added large file support check-in: abb8c966f2 user: rkeene tags: trunk | |
07:50 | Added support for a non-blocking HTTP mode check-in: 145eda8451 user: rkeene tags: trunk | |
07:42 | Updated to correctly encode range check-in: 6add2b1206 user: rkeene tags: trunk | |
Changes
Modified filed.c from [8a7d495917] to [c383e2203f].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <strings.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <time.h> /* Default values */ #define MAX_FAILURE_COUNT 30 #define PORT 8080 #define THREAD_COUNT 10 #define BIND_ADDR "::" | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <strings.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <errno.h> #include <time.h> /* Default values */ #define MAX_FAILURE_COUNT 30 #define PORT 8080 #define THREAD_COUNT 10 #define BIND_ADDR "::" |
︙ | ︙ | |||
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | (unsigned long long) fileinfo->len ); } fprintf(fp, "\r\n"); fflush(fp); 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) { | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | (unsigned long long) fileinfo->len ); } fprintf(fp, "\r\n"); fflush(fp); filed_log_msg("PROCESS_REPLY_COMPLETE FD=... STATUS=20X"); #ifdef FILED_NONBLOCK_HTTP int socket_flags; fd_set rfd, wfd; char sinkbuf[8192]; ssize_t read_ret; FD_ZERO(&rfd); FD_ZERO(&wfd); FD_SET(fd, &rfd); FD_SET(fd, &wfd); socket_flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, socket_flags | O_NONBLOCK); #endif 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) { #ifdef FILED_NONBLOCK_HTTP if (errno == EAGAIN) { sendfile_ret = 0; while (1) { select(fd + 1, &rfd, &wfd, NULL, NULL); if (FD_ISSET(fd, &rfd)) { read_ret = read(fd, sinkbuf, sizeof(sinkbuf)); if (read_ret <= 0) { break; } } if (FD_ISSET(fd, &wfd)) { read_ret = 1; break; } } if (read_ret <= 0) { break; } } else { break; } #else break; #endif } sendfile_len -= sendfile_ret; sendfile_sent += sendfile_ret; if (sendfile_len == 0) { break; } |
︙ | ︙ |