Permalink
Browse files

Don't send last HTTP header and first sendfile chunks at the same time

  • Loading branch information...
1 parent be6396a commit e88527b33146ffb4961c54c83df14c404356e1b6 @jonashaag committed Sep 18, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 bjoern/server.c
View
@@ -193,10 +193,14 @@ ev_io_on_write(struct ev_loop* mainloop, ev_io* watcher, const int events)
if(request->state.use_sendfile) {
/* sendfile */
- if(request->current_chunk && send_chunk(request))
- goto out;
- /* abuse current_chunk_p to store the file fd */
- request->current_chunk_p = PyObject_AsFileDescriptor(request->iterable);
+ if(request->current_chunk) {
+ /* current_chunk contains the HTTP headers */
+ if(send_chunk(request))
+ goto out;
+ assert(!request->current_chunk_p);
+ /* abuse current_chunk_p to store the file fd */
+ request->current_chunk_p = PyObject_AsFileDescriptor(request->iterable);
+ }
if(do_sendfile(request))
goto out;
} else {

0 comments on commit e88527b

Please sign in to comment.