From 82b6fd41125bc69a20f5cd7e139509458ebb6294 Mon Sep 17 00:00:00 2001 From: Andrei Sedoi Date: Wed, 2 Nov 2016 10:46:54 +0000 Subject: [PATCH] docs: handle CURL_POLL_INOUT in multi-uv example --- docs/examples/multi-uv.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index aece4011a..16b66693d 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -176,22 +176,23 @@ int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp, void *socketp) { curl_context_t *curl_context; - if(action == CURL_POLL_IN || action == CURL_POLL_OUT) { - if(socketp) { - curl_context = (curl_context_t *) socketp; - } - else { - curl_context = create_curl_context(s); - } - curl_multi_assign(curl_handle, s, (void *) curl_context); - } + int events = 0; switch(action) { case CURL_POLL_IN: - uv_poll_start(&curl_context->poll_handle, UV_READABLE, curl_perform); - break; case CURL_POLL_OUT: - uv_poll_start(&curl_context->poll_handle, UV_WRITABLE, curl_perform); + case CURL_POLL_INOUT: + curl_context = socketp ? + (curl_context_t *) socketp : create_curl_context(s); + + curl_multi_assign(curl_handle, s, (void *) curl_context); + + if(action != CURL_POLL_IN) + events |= UV_WRITABLE; + if(action != CURL_POLL_OUT) + events |= UV_READABLE; + + uv_poll_start(&curl_context->poll_handle, events, curl_perform); break; case CURL_POLL_REMOVE: if(socketp) {