aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndrei Sedoi <bsnote@gmail.com>2016-11-02 10:46:54 +0000
committerDaniel Stenberg <daniel@haxx.se>2016-11-03 12:32:14 +0100
commit82b6fd41125bc69a20f5cd7e139509458ebb6294 (patch)
tree30a9e98644cc3d2175d6cee46320d71660fbec83 /docs
parente6882ce4846622dab5bef8b0e566062057068bc6 (diff)
docs: handle CURL_POLL_INOUT in multi-uv example
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/multi-uv.c25
1 files 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) {