efl_net_dialer_http: keep fd directly.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 30 Aug 2016 02:35:31 +0000 (23:35 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 30 Aug 2016 03:36:00 +0000 (00:36 -0300)
commitb004b8a4f986f49e23c3314e7f59d4fb8f4fd524
tree84db1cff0c4d60f16a3759f2dedb31bb9b0d45ff
parentf1c691d0f54c13ad76163ce419cbc54f2b3b2afc
efl_net_dialer_http: keep fd directly.

provide curl with CURLOPT_OPENSOCKETFUNCTION and keep the fd in our
private data.

This is required because on _efl_net_dialer_http_efl_io_writer_write()
we may have no fdhandler.

It happened to me while implementing the WebSocket that uses a
bi-directional communication on top of HTTP and the server sent the
whole message, CURL reads:

   recvfrom(7, "...", 16384, 0, NULL, NULL) = 86
   recvfrom(7, "", 16384, 0, NULL, NULL) = 0

After the empty (second) recvfrom(), CURL will remove the fdhandler:

    DBG:ecore_con lib/ecore_con/efl_net_dialer_http.c:482 _efl_net_dialer_http_curlm_socket_manage() dialer=0x4000000040000005 fdhandler=(nil), fd=7, curl_easy=0x5561846ca8d0, flags=0x4

However I should be able to write to this socket, in my case I need to
reply to a PING request with a PONG.
src/lib/ecore_con/ecore_con_url_curl.h
src/lib/ecore_con/efl_net_dialer_http.c