From 3303db79d925d7e712ed16378158d914f1c78293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 6 Nov 2014 02:58:14 -0800 Subject: [PATCH] fix undefined value [skip ci] --- platform/default/http_request_baton_curl.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp index 986191ef8..ecde8618f 100644 --- a/platform/default/http_request_baton_curl.cpp +++ b/platform/default/http_request_baton_curl.cpp @@ -245,13 +245,9 @@ void curl_perform(uv_poll_t *req, int /* status */, int events) { } int handle_socket(CURL * /* handle */, curl_socket_t s, int action, void * /* userp */, void *socketp) { - Socket *socket; - if (action == CURL_POLL_IN || action == CURL_POLL_OUT) { - if (socketp) { - socket = (Socket *)socketp; - } else { - socket = new Socket(s); - } + Socket *socket = (Socket *)socketp; + if (!socket && action != CURL_POLL_REMOVE) { + socket = new Socket(s); curl_multi_assign(multi, s, (void *)socket); } @@ -263,8 +259,8 @@ int handle_socket(CURL * /* handle */, curl_socket_t s, int action, void * /* us socket->start(UV_WRITABLE, curl_perform); break; case CURL_POLL_REMOVE: - if (socketp) { - ((Socket *)socketp)->stop(); + if (socket) { + socket->stop(); curl_multi_assign(multi, s, NULL); } break;