Commit Graph

59 Commits

Author SHA1 Message Date
Cedric BAIL 33c00de365 eo: make efl_future_then have a data pointer in addition of the object pointer.
Summary:
In the case when you have multiple future in flight related to one object, you
couldn't use the previous version of efl_future_then. Now all function calls
take a void* pointer that allow multiple future to have their private data
request data accessible in all the callback.

This should not break released API as Eo.h is not released yet and so
was efl_future_Eina_FutureXXX_then.

Depends on D7332

Reviewers: felipealmeida, segfaultxavi, vitor.sousa, SanghyeonLee, bu5hm4n

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7472

Differential Revision: https://phab.enlightenment.org/D7379
2018-12-07 12:23:11 +01:00
Cedric BAIL 5de51f84fb eo: rename efl_future_Eina_FutureXXX_then in efl_future_then as this has been available for some time.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br>
Differential Revision: https://phab.enlightenment.org/D7327
2018-11-23 11:39:43 -08:00
Mike Blumenkrantz 0e40fad446 ecore_con: make dns resolver thread stop blocking when canceled
Summary:
if the user or system attempts to cancel this thread then it should
stop blocking and exit in order to avoid potentially exiting after
efl has expected ecore-con to stop being active

@fix
fix T7041
Depends on D6354

Reviewers: ManMower, devilhorns

Reviewed By: ManMower

Subscribers: cedric, #committers

Tags: #efl

Maniphest Tasks: T7041

Differential Revision: https://phab.enlightenment.org/D6355
2018-06-25 15:14:31 -04:00
Cedric BAIL 33fd77e9e4 ecore: move close_on_destructor to close_on_invalidate as that describe the behavior best.
Fix all use to correctly behave on invalidate.
2018-05-01 10:39:01 -07:00
Daniel Kolesa fcae7cab27 eolian gen: enable constness generation on property getter impls
This changes a lot of things all across the EFL. Previously,
methods tagged @const had both their external prototype and
internal impl generated with const on object, while property
getters only had const on the external API. This is now changed
and it all has const everywhere.

Ref T6859.
2018-04-17 20:31:55 +02:00
Cedric BAIL 0f7c5582a4 ecore_con: we should just stop using ecore_main_loop_get. 2018-01-03 12:49:10 -08:00
Carsten Haitzler 9bedda14b3 efl loop - rename ecore_main_loop_get to efl_main_loop_get
ecore_main_loop_get() is really a new "eo api" but it's using our old
ecore_* namespace, so move to the new efl namespace.
2018-01-02 16:13:54 +09:00
Jean-Philippe Andre 81bad9f47c ecore_con: Always get the loop on init
In case of init/shutdown/init cycles, the loop EO ID has changed, so it
must be fetched again.
2017-12-18 19:54:31 +09:00
Jean-Philippe Andre a90746378d ecore_con: Avoid safety errors when closing http
When setting EOS on the dialoer, it's possible that it will also get
automatically closed (by a callback). This results in safety check error
messages, while everything is fine (at least I believe it is).
2017-12-18 19:54:31 +09:00
Cedric BAIL d614894d04 ecore: rename efl_loop_Eina_FutureXXX_job to efl_loop_job. 2017-12-11 14:04:09 -08:00
Andy Williams d5dbcdabd1 eo: Rename efl_ref_get to efl_ref_count 2017-11-08 09:30:42 +00:00
Carsten Haitzler aec79f9d0d efl net http - fix protocol error handling to not crash and handle it
if http server doesnt send even a valid http response and just closes
your conenction... dont segv with null pd->cm

@fix
2017-09-17 18:18:12 +09:00
Guilherme Iscaro ec27ceac27 efl_net: Use the new Eina_Future API. 2017-09-04 10:24:00 -03:00
Guilherme Iscaro 493f75587d Ecore_Conn: Set EOS only if the connection is not closed.#algo.
This check prevents that EOS is set on a closed connection.

Fixes T5180
2017-07-28 15:22:51 -03:00
Chris Michael 0652fbe91c ecore-con: Remove unused variable
Gcc complains that 'flags' here may be used uninitialized. In looking
at the code, 'flags' does not seem to be needed in the debug prints
here. If we keep and initialize the variable to 0 during declaration,
it would only ever print out 0 anyway as 'flags' is never changed in the
code.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-19 10:57:43 -04:00
Cedric BAIL 662f7d3310 ecore_con: use new API eina_file_close_on_exec. 2017-04-18 16:56:01 -07:00
Carsten Haitzler eab798c753 ecore_con/efl_net - dedicated threads for network i/o not from the pool
so ecore_con/efl_net were using the standard ecore_thread thread pool
for doing things like dns lookups (that can take multiple minutes
until timeouts) and actual http transactions. similarly they can block
thread workers for long periods or indefinitely thus basically
blocking the whole eocre_thread pool and stopping others from sharing
it. the best solution we have right now is to bypass the thread pool
queue and have dedicated threads for these actions. what we should
have is a dedicated thread pool with each thread taking on N
connections (via select etc.) and the ability to create and destroy
thread pools for specific tasks so you can separate the work out from
other work.  but that is basically a redesign of our thread pool infra
so let's do the quick solution here until that day comes.

this partially addresses D4640

a dedicated thread per image load though is going to be a lot nastier...
2017-02-03 14:57:49 +09:00
Gustavo Sverzut Barbieri 0293c360eb efl_net_dialer_http: check for finished handles after unpause.
After we call curl_multi_socket_action() we must call
_efl_net_dialer_http_curlm_check() in order to call
curl_multi_info_read() and be notified of handles that were
finished. Otherwise the handle is gone and we'll be waiting for an
action that will never happen.

Fixes T5079
2017-02-01 16:26:38 -02:00
Carsten Haitzler bd2f189d4c ecore_con - move libproxy to a slave binary with stdin/out msging
so here's the ugly problem. libproxy. yes. we've discussed memory
usage (e.g. it may have to execute javascript and pull in lots of deps
etc.) but we dlopene'd on the fly. ok... but this didn't solve another
issue i hit:

libproxy was causing enlightenment to abort(). some internal bit of
libproxy was raising a c++ exception. this wasn't caught. this causes
an abort(). takes down your entire desktop. FANTASTIC. this is bad. i
wouldnt' expect a library we depend on to be THIS anti-social but
libproxy seemingly is. it SHOULd catch its error sand just propagate
back to us so we can handle gracefully.

there reall is no way around this - isolate libproxy. it's even worse
that libproxy can load arbitrary modules that come from anywhere sho
who knows what issues this can cause. isolation is the best solution i
can think of.

so this makes an elf+net_proxy_helper we spawn the first time we need
a proxy lookup. we re-use that binary again and again until it exits
(it should exit after 10 seconds of being idle with no requests coming
in/pending). it'll respawn again later if needed. this involves now
the efl net threads having to marshall back to mainloop to do the
spawn and to write to the proxy process (reading is done by async exe
data events and the data is passed down a thread queue to the waitng
efl net thread). if the exe dies with pending requests unanswered then
it's respawned again and the req's are re-sent to it... just in case.
it has a limit on how often it'll respawn quickly.

this seems to work in my limited testing. this ALSO now isolates
memory usage of libproxy to another slave process AND this process
will die taking its memory with it once it's been idle for long
enough. that;s also another good solution to keeping libproxy impact
at bay.
2017-01-09 15:29:33 +09:00
Gustavo Sverzut Barbieri 08c38713ce do not emit events from efl_io_closer_close() on destructor.
On destructor we're not supposed to emit events, I even thought that
would be implicit, but it's not. If we do, for example an event
handler that would 'efl_del()' on "EFL_IO_CLOSER_EVENT_CLOSED" would
trigger too-many unrefs.
2016-12-20 10:18:32 -02:00
Gustavo Sverzut Barbieri 0073e87761 efl_net_dialer_http: fix HEAD requests.
We do not need to keep a "only_head" flag, but we must set
CURLOPT_NOBODY instead of going the "CUSTOMREQUEST" route, otherwise
curl won't follow redirects, etc.
2016-12-12 03:17:35 -02:00
Gustavo Sverzut Barbieri d52daf8dd7 efl_net_dialer_http: fix reference check.
With the last patch to fix delete-from-curl callback it went too much,
considering it was always dead (in the test scenario it was, so it was
"right"), but broke normal cases.
2016-12-12 03:16:07 -02:00
Gustavo Sverzut Barbieri e9a72ea8f4 efl_net: spell check s/revogation/revocation/g
Sorry, in pt_BR it's revoGar... so I did misspell :-)
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri 2945b972ef efl_net_dialer_http: fix delete-from-CURL callback.
This was annoying to identify as the sequence is kinda difficult to
get, but Terminology was doing a HEAD request and it was triggering
this case in particular.

Fixes T4975.
2016-12-09 22:18:18 -02:00
Gustavo Sverzut Barbieri 345bba3ef1 efl_net_dialer_http: fix build on windows.
Windows time_t is not a long, but long-long, then stick with int64_t
so it works everywhere (converts to time_t internally).

And there is no gmtime_r(), then use the gmtime() if not detected.
2016-12-09 19:32:14 -02:00
Gustavo Sverzut Barbieri da143edd8c efl_net_dialer_http: POST also allows resizing.
resizing the dialer results in changing the request content length,
which is useful when uploading files AND posting data.
2016-11-29 16:03:13 -02:00
Gustavo Sverzut Barbieri 4aca800bde efl_net_dialer_http: export SSL controls.
verify peer, hostname and set CA/CRL files.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri 3cf20ea8e8 efl_net_dialer_http: special headers and date parse/serialize.
CURL needs some special curl_easy_setopt() calls to enable automatic
gzip deflate (CURLOPT_ENCODING) and
If-Modified-Since/If-Unmodified-Since logic.

As If-Modified-Since/If-Unmodified-Since requires a timestamp string,
let's expose class methods to handle those.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri 5c7b984746 efl_net_dialer_http: only close if not closed yet.
since eos_set() emits an event the user may have closed from there.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri b4ed72518d efl_net_dialer_http: export read size.
In the legacy wrapper I'll need that.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri c2cb5defe3 efl_net_dialer_http: use efl_loop_fd now that it's fixed.
now that efl_loop_fd manages callbacks -> Ecore_Fd_Handler properly,
we can remove the old code.
2016-11-24 02:13:32 -02:00
Gustavo Sverzut Barbieri 5818dc71da efl_net: use SOCKET_FMT to format SOCKET so it works on UNIX and Windows.
On Windows SOCKET is unsigned, thus will cause sign errors when
formatting with "%d" or comparing with signed values.

On UNIX it was quiet and easy to miss, thus a new #define can be used
to check for those. It will use 'unsigned long' as SOCKET, thus will
complain out loud and not even work correctly when using pointers on
64bits UNIX on mistakes -- which should improve the situation.

This helped to fix lots of missing conversions, all fixed.

This partially addresses D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri 7917fa4ebf efl_net_dialer_http: NULL-ify thread pointer when it's gone.
on thread cancel and end, we should nullify the pointer if it was
still set.
2016-11-10 00:10:11 -02:00
Gustavo Sverzut Barbieri fa3a2e6489 efl_net_dialer_http: fix short downloads.
for short downloads the CURL handle will be done before the client had
time to read it, like done by efl_io_copier's job. We need to wait it
drain before we emit eos/closed.
2016-10-26 23:19:46 -02:00
Gustavo Sverzut Barbieri cddbce8900 efl_net_*: improve WIN32.
Thanks to vtorri for poiting out about close() is not the correct
socket function, we should use closesocket() instead.

Also defined SOCKET to int on Linux so we can use the same 'type' and
avoid lots of ifdef in our code. On Windows it's unsigned, thus would
cause some warnings about incorrect signed comparison.
2016-10-22 21:49:01 -02:00
Gustavo Sverzut Barbieri e6a78bd02a efl_net: play better with WIN32.
Defined INVALID_SOCKET=-1 and SOCKET_ERROR=-1 on non-Windows platforms
so we can keep the same construct 'function() == error' and it should
work on POSIX and windows.

I cannot test these on Windows, but the situation should be improved
with this commit.
2016-10-22 13:15:16 -02:00
Jean-Philippe Andre 7f6f282210 Efl.Loop.User: Use prefix to rename efl_loop_user_loop_get
efl_loop_user_loop_get is idiotic. efl_loop_get should be good enough.
2016-10-06 12:24:59 +09:00
Gustavo Sverzut Barbieri f0f9c5d24a libproxy: dlopen() and make it runtime optional. 2016-09-20 15:00:48 -03:00
Gustavo Sverzut Barbieri 8550a33b27 efl_net_dialer_http: use libproxy.
query libproxy in a thread (since it's nasty and blocks), then apply
proxy to curl and execute the request.
2016-09-19 10:01:51 -03:00
Gustavo Sverzut Barbieri eb9a1f13a3 efl_net_dialer_http: do eos on error. 2016-09-19 01:18:14 -03:00
Cedric Bail 03797a33ab ecore,ecore_con: fix migration to efl_future.
Efl_Future actually work with weak reference. So you do not need to
set things to NULL, but you actually need to register the memory location
of the future with efl_future_use.
2016-09-16 19:13:59 -07:00
Cedric Bail 95093095f3 ecore_con: migrate use of Eina_Promise to Efl_Future. 2016-09-15 21:49:08 -07:00
Gustavo Sverzut Barbieri 704d0818d7 efl_net_dialer_http: emit eos only at the end.
http copiers were never finishing since eos was being reset to FALSE
before the I/O copier job executed.
2016-09-12 13:18:28 -03:00
Gustavo Sverzut Barbieri ea7bc821d5 efl_io_closer: add close_on_exec and close_on_destructor properties.
the purpose of these properties are to make it more uniform the
handling of these auto-close behavior.
2016-09-12 13:18:28 -03:00
Tom Hacohen 9c779dca90 Rename efl_self to efl_added
It has been discussed on the ML (thread: "[RFC] rename efl_self") and
IRC, and has been decided we should rename it to this in order to avoid
confusion with the already established meaning of self which is very
similar to what we were using it for, but didn't have complete overlap.

Kudos to Marcel Hollerbach for initiating the discussion and
fighting for it until he convinced a significant mass. :)

This commit breaks API, and depending on compiler potentially ABI.

@feature
2016-09-05 16:59:56 +01:00
Gustavo Sverzut Barbieri 57e765a758 efl_net_dialer_http: use CURLOPT_NOSIGNAL.
EFL uses its own signal handlers, so we must disable CURL's usage of
those.
2016-09-02 00:08:50 -03:00
Gustavo Sverzut Barbieri 6ddd01bffb efl_net_dialer_http: fix interaction with CURL on receiving data.
When CURLOPT_WRITEFUNCTION returns less then the requested amount,
CURL will fail, not call us back with the remaining data.

Then in such cases we must pause CURL and read nothing.

When unpausing we need to kick curl with timeout action so FD handlers
will be re-arranged.

Last but not least, sync our buffer limit with CURL, otherwise it may
always fail if we're smaller than CURL.
2016-09-02 00:08:50 -03:00
Gustavo Sverzut Barbieri d12ff74f5f efl_net_dialer_http: allow delete/close from CURL callbacks.
CURL doesn't play nice if handles are deleted or modified while it's
dispatching the callbacks, then we must not touch the CURL* easy
handle in those cases, just dissociate the handle from object and
schedule a job to do the deletion later.

Also, since from CURL callbacks we do not have the reference to the
object, if they are deleted from inside the callback, users of 'pd'
will crash. Thus keep an extra reference while the object and its
private data are in use.

The curl_multi_info_read() is used to notify of errors and
end-of-stream, if we do callback directly from there, the user may
efl_del(dialer), which will result in the "pd->easy" being destroyed
with curl_easy_cleanup() then "cm" and "cm->multi" being destroyed.

Thus postpone that action and keep a list of finished objects, calling
their event handlers which can delete the object (or siblings), thus
ref before dispatching and unref afterwards, taking care to monitor
EFL_EVENT_DEL so we do not use stale objects.
2016-09-02 00:08:50 -03:00
Vitor Sousa f02ff462e7 efl callbacks: update some events calls to no longer trigger legacy callbacks 2016-08-30 13:59:59 -03:00
Tom Hacohen d5e321466e Efl object: Rename Eo_Event -> Efl_Event.
This is the last step of the Eo renaming efforts.
2016-08-30 13:34:10 +01:00