summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-08-24 14:33:33 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-08-24 14:33:33 -0300
commitf125942231fae282f02ab3a321dce7384c8f9119 (patch)
treeb9332339d467bd8115112713f8b8020cfb6d6e06 /src
parente3ee477140bb760dfffc8e32c0a3e9a961664c3d (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_con/ecore_con_url_curl.c22
-rw-r--r--src/lib/ecore_con/ecore_con_url_curl.h15
-rw-r--r--src/lib/ecore_con/efl_net_dialer_http.c19
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)
149#undef _MAP 149#undef _MAP
150 150
151 default: 151 default:
152 ERR("unexpected error CURcode=%d '%s', not mapped", 152 ERR("unexpected error CURLcode=%d '%s', not mapped",
153 code, _c->curl_easy_strerror(code)); 153 code, _c->curl_easy_strerror(code));
154 return EINVAL; 154 return EINVAL;
155 } 155 }
156} 156}
157 157
158Eina_Error
159_curlmcode_to_eina_error(const CURLMcode code)
160{
161 switch (code) {
162 case CURLM_OK: return 0;
163 case CURLM_BAD_HANDLE: return EBADF;
164 case CURLM_BAD_EASY_HANDLE: return EBADF;
165 case CURLM_OUT_OF_MEMORY: return ENOMEM;
166 case CURLM_INTERNAL_ERROR: EIO; /* not exact, but the error should happen so not much of a problem */
167 case CURLM_BAD_SOCKET: return ENOTSOCK;
168 case CURLM_UNKNOWN_OPTION: return EINVAL;
169 case CURLM_ADDED_ALREADY: return EALREADY;
170
171 default:
172 ERR("unexpected error CURLMcode=%d '%s', not mapped",
173 code, _c->curl_multi_strerror(code));
174 return EINVAL;
175 }
176}
177
158static void 178static void
159_c_init_errors(void) 179_c_init_errors(void)
160{ 180{
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 @@
14// defined here. see curl headers to get them from 14// defined here. see curl headers to get them from
15typedef enum 15typedef enum
16{ 16{
17 CURLM_CALL_MULTI_PERFORM = -1, 17 CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
18 CURLM_OK = 0 18 curl_multi_socket*() soon */
19 CURLM_OK,
20 CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
21 CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
22 CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
23 CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
24 CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
25 CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
26 CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
27 attempted to get added - again */
28 CURLM_LAST
19} CURLMcode; 29} CURLMcode;
20 30
21#ifndef curl_socket_typedef 31#ifndef curl_socket_typedef
@@ -421,5 +431,6 @@ extern double _c_timeout;
421Eina_Bool _c_init(void); 431Eina_Bool _c_init(void);
422void _c_shutdown(void); 432void _c_shutdown(void);
423Eina_Error _curlcode_to_eina_error(const CURLcode code); 433Eina_Error _curlcode_to_eina_error(const CURLcode code);
434Eina_Error _curlmcode_to_eina_error(const CURLMcode code);
424 435
425#endif 436#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
1222_efl_net_dialer_http_efl_io_writer_write(Eo *o, Efl_Net_Dialer_Http_Data *pd, Eina_Slice *slice, Eina_Slice *remaining) 1222_efl_net_dialer_http_efl_io_writer_write(Eo *o, Efl_Net_Dialer_Http_Data *pd, Eina_Slice *slice, Eina_Slice *remaining)
1223{ 1223{
1224 Eina_Error err = EINVAL; 1224 Eina_Error err = EINVAL;
1225 CURLMcode r; 1225 CURLMcode rm;
1226 CURLcode re;
1226 1227
1227 EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINVAL); 1228 EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINVAL);
1228 EINA_SAFETY_ON_TRUE_GOTO(efl_io_closer_closed_get(o), error); 1229 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
1232 pd->send.slice = *slice; 1233 pd->send.slice = *slice;
1233 efl_io_writer_can_write_set(o, EINA_FALSE); 1234 efl_io_writer_can_write_set(o, EINA_FALSE);
1234 pd->pause &= ~CURLPAUSE_SEND; 1235 pd->pause &= ~CURLPAUSE_SEND;
1235 r = curl_easy_pause(pd->easy, pd->pause); 1236 re = curl_easy_pause(pd->easy, pd->pause);
1236 if (r != CURLM_OK) 1237 if (re != CURLE_OK)
1237 { 1238 {
1238 err = _curlcode_to_eina_error(r); 1239 err = _curlcode_to_eina_error(re);
1239 ERR("dialer=%p could not unpause send (flags=%#x): %s", 1240 ERR("dialer=%p could not unpause send (flags=%#x): %s",
1240 o, pd->pause, eina_error_msg_get(err)); 1241 o, pd->pause, eina_error_msg_get(err));
1241 goto error; 1242 goto error;
1242 } 1243 }
1243 1244
1244 pd->error = 0; 1245 pd->error = 0;
1245 r = curl_multi_socket_action(pd->cm->multi, 1246 rm = curl_multi_socket_action(pd->cm->multi,
1246 ecore_main_fd_handler_fd_get(pd->fdhandler), 1247 ecore_main_fd_handler_fd_get(pd->fdhandler),
1247 CURL_CSELECT_OUT, &pd->cm->running); 1248 CURL_CSELECT_OUT, &pd->cm->running);
1248 if (r != CURLM_OK) 1249 if (rm != CURLM_OK)
1249 { 1250 {
1250 err = _curlcode_to_eina_error(r); 1251 err = _curlcode_to_eina_error(rm);
1251 ERR("dialer=%p could not trigger socket=%d action: %s", 1252 ERR("dialer=%p could not trigger socket=%d action: %s",
1252 o, ecore_main_fd_handler_fd_get(pd->fdhandler), 1253 o, ecore_main_fd_handler_fd_get(pd->fdhandler),
1253 eina_error_msg_get(err)); 1254 eina_error_msg_get(err));