Created
January 3, 2013 20:38
-
-
Save mnunberg/4447029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/event.c b/src/event.c | |
| index f474f05..841a1b9 100644 | |
| --- a/src/event.c | |
| +++ b/src/event.c | |
| @@ -295,6 +295,7 @@ void lcb_server_event_handler(lcb_socket_t sock, short which, void *arg) | |
| { | |
| lcb_server_t *c = arg; | |
| (void)sock; | |
| + short which_new = LCB_READ_EVENT; | |
| if (which & LCB_WRITE_EVENT) { | |
| if (do_send_data(c) != 0) { | |
| @@ -313,17 +314,18 @@ void lcb_server_event_handler(lcb_socket_t sock, short which, void *arg) | |
| return; | |
| } | |
| } | |
| - | |
| - which = 0; | |
| if (c->output.nbytes || c->input.nbytes) { | |
| - which |= LCB_WRITE_EVENT; | |
| - } | |
| - if (c->cmd_log.nbytes) { | |
| - which |= LCB_READ_EVENT; | |
| + /** | |
| + * If we have data in the read buffer, we need to make sure the event | |
| + * still gets delivered despite nothing being in the actual TCP read | |
| + * buffer. Since writes will typically not block, we hinge the next | |
| + * read operation on write-ability | |
| + */ | |
| + which_new |= LCB_WRITE_EVENT; | |
| } | |
| - if (which) { | |
| + if (which_new != which) { | |
| c->instance->io->v.v0.update_event(c->instance->io, c->sock, | |
| - c->event, which, c, | |
| + c->event, which_new, c, | |
| lcb_server_event_handler); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment