barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f125942231fae282f02ab3a321dce7384c8f9119

commit f125942231fae282f02ab3a321dce7384c8f9119
Author: Gustavo Sverzut Barbieri <[email protected]>
Date:   Wed Aug 24 14:33:33 2016 -0300

    efl_net_dialer_http: use the proper error code
    
    CURLcode is for curl_easy, while CURLMcode is for curl_multi.
    
    Thanks to clang that spotted it.
---
 src/lib/ecore_con/ecore_con_url_curl.c  | 22 +++++++++++++++++++++-
 src/lib/ecore_con/ecore_con_url_curl.h  | 15 +++++++++++++--
 src/lib/ecore_con/efl_net_dialer_http.c | 19 ++++++++++---------
 3 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/src/lib/ecore_con/ecore_con_url_curl.c 
b/src/lib/ecore_con/ecore_con_url_curl.c
index 92becd3..e28326e 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.c
+++ b/src/lib/ecore_con/ecore_con_url_curl.c
@@ -149,12 +149,32 @@ _curlcode_to_eina_error(const CURLcode code)
 #undef _MAP
 
     default:
-       ERR("unexpected error CURcode=%d '%s', not mapped",
+       ERR("unexpected error CURLcode=%d '%s', not mapped",
            code, _c->curl_easy_strerror(code));
        return EINVAL;
    }
 }
 
+Eina_Error
+_curlmcode_to_eina_error(const CURLMcode code)
+{
+   switch (code) {
+    case CURLM_OK: return 0;
+    case CURLM_BAD_HANDLE: return EBADF;
+    case CURLM_BAD_EASY_HANDLE: return EBADF;
+    case CURLM_OUT_OF_MEMORY: return ENOMEM;
+    case CURLM_INTERNAL_ERROR: EIO; /* not exact, but the error should happen 
so not much of a problem */
+    case CURLM_BAD_SOCKET: return ENOTSOCK;
+    case CURLM_UNKNOWN_OPTION: return EINVAL;
+    case CURLM_ADDED_ALREADY: return EALREADY;
+
+    default:
+       ERR("unexpected error CURLMcode=%d '%s', not mapped",
+           code, _c->curl_multi_strerror(code));
+       return EINVAL;
+   }
+}
+
 static void
 _c_init_errors(void)
 {
diff --git a/src/lib/ecore_con/ecore_con_url_curl.h 
b/src/lib/ecore_con/ecore_con_url_curl.h
index 0f6b375..ff9ad17 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.h
+++ b/src/lib/ecore_con/ecore_con_url_curl.h
@@ -14,8 +14,18 @@
 // defined here. see curl headers to get them from
 typedef enum
 {
-   CURLM_CALL_MULTI_PERFORM = -1,
-   CURLM_OK = 0
+  CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
+                                    curl_multi_socket*() soon */
+  CURLM_OK,
+  CURLM_BAD_HANDLE,      /* the passed-in handle is not a valid CURLM handle */
+  CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
+  CURLM_OUT_OF_MEMORY,   /* if you ever get this, you're in deep sh*t */
+  CURLM_INTERNAL_ERROR,  /* this is a libcurl bug */
+  CURLM_BAD_SOCKET,      /* the passed in socket argument did not match */
+  CURLM_UNKNOWN_OPTION,  /* curl_multi_setopt() with unsupported option */
+  CURLM_ADDED_ALREADY,   /* an easy handle already added to a multi handle was
+                            attempted to get added - again */
+  CURLM_LAST
 } CURLMcode;
 
 #ifndef curl_socket_typedef
@@ -421,5 +431,6 @@ extern double _c_timeout;
 Eina_Bool _c_init(void);
 void _c_shutdown(void);
 Eina_Error _curlcode_to_eina_error(const CURLcode code);
+Eina_Error _curlmcode_to_eina_error(const CURLMcode code);
 
 #endif
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c 
b/src/lib/ecore_con/efl_net_dialer_http.c
index 55b008b..b873106 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -1222,7 +1222,8 @@ EOLIAN static Eina_Error
 _efl_net_dialer_http_efl_io_writer_write(Eo *o, Efl_Net_Dialer_Http_Data *pd, 
Eina_Slice *slice, Eina_Slice *remaining)
 {
    Eina_Error err = EINVAL;
-   CURLMcode r;
+   CURLMcode rm;
+   CURLcode re;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINVAL);
    EINA_SAFETY_ON_TRUE_GOTO(efl_io_closer_closed_get(o), error);
@@ -1232,22 +1233,22 @@ _efl_net_dialer_http_efl_io_writer_write(Eo *o, 
Efl_Net_Dialer_Http_Data *pd, Ei
    pd->send.slice = *slice;
    efl_io_writer_can_write_set(o, EINA_FALSE);
    pd->pause &= ~CURLPAUSE_SEND;
-   r = curl_easy_pause(pd->easy, pd->pause);
-   if (r != CURLM_OK)
+   re = curl_easy_pause(pd->easy, pd->pause);
+   if (re != CURLE_OK)
      {
-        err = _curlcode_to_eina_error(r);
+        err = _curlcode_to_eina_error(re);
         ERR("dialer=%p could not unpause send (flags=%#x): %s",
             o, pd->pause, eina_error_msg_get(err));
         goto error;
      }
 
    pd->error = 0;
-   r = curl_multi_socket_action(pd->cm->multi,
-                                ecore_main_fd_handler_fd_get(pd->fdhandler),
-                                CURL_CSELECT_OUT, &pd->cm->running);
-   if (r != CURLM_OK)
+   rm = curl_multi_socket_action(pd->cm->multi,
+                                 ecore_main_fd_handler_fd_get(pd->fdhandler),
+                                 CURL_CSELECT_OUT, &pd->cm->running);
+   if (rm != CURLM_OK)
      {
-        err = _curlcode_to_eina_error(r);
+        err = _curlcode_to_eina_error(rm);
         ERR("dialer=%p could not trigger socket=%d action: %s",
             o, ecore_main_fd_handler_fd_get(pd->fdhandler),
             eina_error_msg_get(err));

-- 


Reply via email to