diff options
Diffstat (limited to 'src/daemon/response.c')
-rw-r--r-- | src/daemon/response.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/daemon/response.c b/src/daemon/response.c index e630019c..7d9ae17c 100644 --- a/src/daemon/response.c +++ b/src/daemon/response.c | |||
@@ -273,7 +273,7 @@ file_reader (void *cls, uint64_t pos, char *buf, size_t max) | |||
273 | int ret; | 273 | int ret; |
274 | 274 | ||
275 | pthread_mutex_lock (&response->mutex); | 275 | pthread_mutex_lock (&response->mutex); |
276 | (void) lseek (response->fd, pos, SEEK_SET); | 276 | (void) lseek (response->fd, pos + response->fd_off, SEEK_SET); |
277 | ret = read (response->fd, buf, max); | 277 | ret = read (response->fd, buf, max); |
278 | pthread_mutex_unlock (&response->mutex); | 278 | pthread_mutex_unlock (&response->mutex); |
279 | return ret; | 279 | return ret; |
@@ -301,10 +301,12 @@ free_callback (void *cls) | |||
301 | * | 301 | * |
302 | * @param size size of the data portion of the response | 302 | * @param size size of the data portion of the response |
303 | * @param fd file descriptor referring to a file on disk with the data | 303 | * @param fd file descriptor referring to a file on disk with the data |
304 | * @param off offset to start reading from in the file | ||
304 | * @return NULL on error (i.e. invalid arguments, out of memory) | 305 | * @return NULL on error (i.e. invalid arguments, out of memory) |
305 | */ | 306 | */ |
306 | struct MHD_Response *MHD_create_response_from_fd (size_t size, | 307 | struct MHD_Response *MHD_create_response_from_fd_at_offset (size_t size, |
307 | int fd) | 308 | int fd, |
309 | off_t offset) | ||
308 | { | 310 | { |
309 | struct MHD_Response *ret; | 311 | struct MHD_Response *ret; |
310 | 312 | ||
@@ -316,11 +318,29 @@ struct MHD_Response *MHD_create_response_from_fd (size_t size, | |||
316 | if (ret == NULL) | 318 | if (ret == NULL) |
317 | return NULL; | 319 | return NULL; |
318 | ret->fd = fd; | 320 | ret->fd = fd; |
321 | ret->fd_off = offset; | ||
319 | ret->crc_cls = ret; | 322 | ret->crc_cls = ret; |
320 | return ret; | 323 | return ret; |
321 | } | 324 | } |
322 | 325 | ||
323 | 326 | ||
327 | |||
328 | |||
329 | /** | ||
330 | * Create a response object. The response object can be extended with | ||
331 | * header information and then be used any number of times. | ||
332 | * | ||
333 | * @param size size of the data portion of the response | ||
334 | * @param fd file descriptor referring to a file on disk with the data | ||
335 | * @return NULL on error (i.e. invalid arguments, out of memory) | ||
336 | */ | ||
337 | struct MHD_Response *MHD_create_response_from_fd (size_t size, | ||
338 | int fd) | ||
339 | { | ||
340 | return MHD_create_response_from_fd_at_offset (size, fd, 0); | ||
341 | } | ||
342 | |||
343 | |||
324 | /** | 344 | /** |
325 | * Create a response object. The response object can be extended with | 345 | * Create a response object. The response object can be extended with |
326 | * header information and then be used any number of times. | 346 | * header information and then be used any number of times. |