View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001679 | libmicrohttpd | other | public | 2011-05-08 12:25 | 2011-05-20 22:19 |
| Reporter | tommie | Assigned To | Christian Grothoff | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 0.9.10 | ||||
| Summary | 0001679: MHD_create_response_from_fd(_at_offset) does not complete in chunked mode. | ||||
| Description | Reading the code of src/daemon/response.c, I would expect MHD_create_response_from_fd(MHD_SIZE_UNKNOWN, ...) to work since MHD_c_r_f_callback() allows MHD_SIZE_UNKNOWN. When testing, however, it seems that the response never completes. Data is transferred, but the final (empty) chunk is nowhere to be seen. Looking at file_reader, I think the EOF case isn't handled correctly. Simply returning the result of read(2) will not use the special MHD_CONTENT_READER_* values. Given that the FD is in blocking mode, I suggest applying the attached patch. Adding a clarifying comment to MHD_c_r_f_fd(_at_offset) about the need for blocking mode is probably a nice extra. | ||||
| Additional Information | Tested on Linux 2.6 with internal select. | ||||
| Tags | No tags attached. | ||||
| Attached Files | response_fd.patch (534 bytes)
Index: src/daemon/response.c =================================================================== --- src/daemon/response.c (revision 15147) +++ src/daemon/response.c (working copy) @@ -272,7 +272,10 @@ struct MHD_Response *response = cls; (void) lseek (response->fd, pos + response->fd_off, SEEK_SET); - return read (response->fd, buf, max); + ssize_t n = read (response->fd, buf, max); + if (n == 0) return MHD_CONTENT_READER_END_OF_STREAM; + if (n < 0) return MHD_CONTENT_READER_END_WITH_ERROR; + else return n; } | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-05-08 12:25 | tommie | New Issue | |
| 2011-05-08 12:25 | tommie | File Added: response_fd.patch | |
| 2011-05-08 21:55 | Christian Grothoff | Note Added: 0004326 | |
| 2011-05-08 21:55 | Christian Grothoff | Status | new => resolved |
| 2011-05-08 21:55 | Christian Grothoff | Resolution | open => fixed |
| 2011-05-08 21:55 | Christian Grothoff | Assigned To | => Christian Grothoff |
| 2011-05-20 22:19 | Christian Grothoff | Status | resolved => closed |