Commit Graph

50 Commits

Author SHA1 Message Date
Vincent Torri 092114ecc8 bin/eet and ecore_con: remove Evil.h when not necessary and include evil_private.h when necessary
Test Plan: compilation

Reviewers: raster, zmike, cedric

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8911
2019-05-17 13:51:50 -04:00
Christopher Michael e43b644168 ecore_con: Fix dereferencing of null pointer
Summary:
Coverity reports that 'svr' might be NULL here, so we should check it
is valid before trying to use it.

Fixes Coverity CID1396990

@fix

Depends on D8320

Reviewers: raster, cedric, q66, zmike, bu5hm4n, stefan

Reviewed By: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8321
2019-03-14 07:22:54 -04:00
Mike Blumenkrantz 36661a436e efl-net: namespace events to avoid naming conflicts
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8260
2019-03-08 12:17:51 -08:00
Wonki Kim 1cdedaa33b ecore_con: Fix potentional problems around ecore_con
non-thread safe functions are used like rand(), strerror().
this patch replace them with thread safe one.
and also this patch contains a change to fix a memory leak problem.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7917
2019-02-13 16:37:08 -08:00
Cedric BAIL 67993500da ecore_con: handle timeout of the attempt to connect.
This has been the fix that prevent random ecore_con DNS tests to fail for me. This should also in case
of failure make the timeout of the ecore_con itself be honored which wasn't anymore.

@fix

Differential Revision: https://phab.enlightenment.org/D7402
2018-12-06 09:29:29 +01:00
Carsten Haitzler 95a538d1f8 ecore con - fix buffer truncate warnign by a bigger buffer 2018-11-09 11:43:59 +00:00
junsu choi ecc6fe749c ecore_con_legacy: fix coverity issues (use after free)
Summary: for hard failures (highly unlikely), the handle would be deleted and the next use would crash.

Test Plan: N/A

Reviewers: Jaehyun_Cho, zmike, cedric, bu5hm4n

Reviewed By: bu5hm4n

Subscribers: bu5hm4n, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7139
2018-10-08 11:19:53 +09:00
Mike Blumenkrantz 683cddf90c ecore-con/legacy: kill server with DEL event if a dialer error occurs
Summary:
in the course of the efl-net rewrite, the previous relied-upon behavior
sequence of error -> disconnect -> del was broken, and error events no
longer triggered disconnects or server deletion.

the failure was caused by a check for the 'connecting' flag, preventing
DEL events from being triggered

further, the ordering of the events was flipped from ERROR -> DEL to
DEL -> ERROR; this is also fixed now

this caused any failed connection to leak the entire server connection
since existing handlers for the del event were never triggered and the
server was never destroyed

@fix
fix T6330

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #committers

Tags: #efl

Maniphest Tasks: T6330

Differential Revision: https://phab.enlightenment.org/D6481
2018-07-03 12:42:00 -04:00
Alastair Poole d1cbd161bd Patch for T6342
Summary: Deprecate SSLv3.

Reviewers: zmike, raster, devilhorns

Reviewed By: zmike

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6334
2018-06-20 14:17:25 +01:00
junsu choi 4db762ee6c ecore_con : Fix that null pointer access for segmentation fault
Summary:
"cl->svr" was to be null on line 281.
This problem occurred from 384f30c8ec.
Replacing "cl->svr" with "svr" corrects the error
while preserving the changes in 384f30c8ec.

Test Plan: N/A

Reviewers: #committers, cedric, Hermet, zmike

Subscribers: bowonryu, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6255
2018-06-07 10:49:42 -04:00
Cedric BAIL b8396add70 ecore_con: efl_net_socket_ssl_adopted_get is EFL_NET_SOCKET_SSL_PROTECTED. 2018-05-25 10:40:56 -07:00
junsu choi 7ef4ab6b88 ecore_con : Fix class check to check inner_socket class
Summary:
cl->socket is a Efl.Net.Socket_Simple. it is not inherit the Efl.Loop.fd class.
and The target of the class check have to be the inner_socket.
But inner_socket is Efl.Net.Socket_Ssl. Efl.Net.Socket_Ssl class is not inherit FD class.
Efl.Net.Socket_Tcp is inherit Efl.Loop.fd class. So, Need to add Efl.Net.Socket_Tcp to inheritance.
(The server side is a similar hierarchy. (ssl -> tcp -> ip -> fd))

Test Plan: N/A

Reviewers: cedric, jypark, myoungwoon, zmike, barbieri

Reviewed By: cedric

Subscribers: #committers, bowonryu, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6168

Reviewed-by: Cedric BAIL <cedric@osg.samsung.com>
2018-05-25 10:07:05 -07:00
Cedric BAIL 384f30c8ec ecore_con: disconnect from the server as soon as it request it.
Ecore_Event can still be in flight while the client get freed by the server.
We are protected agaist that and keep the client partially alive until the event
are processed, but we need to disconnect from the server as soon as possible
as we might outlive the server.
2018-05-24 16:02:21 -07:00
Cedric Bail 301340baf6 ecore_con: allow for NULL to do nothing. 2018-05-24 16:02:20 -07:00
Cedric BAIL 7ca25cae0f ecore: correct lifecycle of object used by Ecore_Con legacy.
Differential Revision: https://phab.enlightenment.org/D6080
2018-05-24 16:02:18 -07:00
YeongJong Lee 6fdc3794eb ecore_con: add check for invalid space("") name
Summary:
space("") name check had existed, but it was removed on f4306d654d
(in the _efl_network_connector_efl_object_finalize)
This patch restore the safety checks

Reviewers: barbieri, Hermet, Jaehyun_Cho, myoungwoon, zmike

Reviewed By: zmike

Subscribers: cedric, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6177
2018-05-18 13:47:04 -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
Carsten Haitzler 2fb5cc3ad0 efl_add_ref - fis to use efl_add properly with a parent.
fixes bc18b7e7ad and
168849e8a0
2018-03-29 13:30:55 +09:00
Cedric BAIL bc18b7e7ad efl: replace efl_del with efl_unref for cases where no parent exists
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:57 -07:00
Cedric BAIL 4c4177ac20 efl: use efl_add_ref to create objects which have no parent
Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2018-03-20 17:20:56 -07:00
Carsten Haitzler 1c74aaa7e9 Revert "cxx: Fix manual code after efl_app change."
This reverts commit 135154303b.

Revert "efl: move signal events from efl.loop to efl.app"
This reverts commit 3dbca39f98.

Revert "efl: add test suite for efl_app"
This reverts commit 3e94be5d73.

Revert "efl: create Efl.App class, the parent of Efl.Loop"
This reverts commit 28fe00b94e.

Go back to before efl.app because I think this should be done with
superclassing here not a parent object. reasons?

1. multiple loops per single thread make no sense. so if multilpe loop
objects they wont be contained in a single app object and then deleted
like this.
2. the app object is not really sharable in this design so it cant be
accessed from other threads
3. it makes it harder to get the main loop or app object (well 2 func
calls one calling the other and more typing. it is longer to type and
more work where it is not necessary, and again it can't work from
other threads unless we go duplicating efl.app per thread and then
what is the point of splittyign out the signal events from efl.loop
then?)

etc.
2018-03-03 13:40:33 +09:00
Mike Blumenkrantz 28fe00b94e efl: create Efl.App class, the parent of Efl.Loop 2018-02-26 14:02:51 -05:00
Cedric BAIL 7db7d84fa2 ecore_con: missed compiler warning. 2018-01-25 09:54:36 -08:00
Cedric BAIL fb3e49d66d ecore_con: restore ability for negative port on local connection.
Thanks make check.
2018-01-25 09:40:20 -08:00
Carsten Haitzler 3f8c282544 ecore-con pass port into err print 2018-01-26 01:53:58 +09:00
Carsten Haitzler eb951e99a6 ecore_con - give error output if port num is invalid 2018-01-26 01:04:12 +09:00
Myoungwoon Roy, Kim 1837253935 ecore_con: Check for the valid port number
Summary:
This patch checks whether the port number is valid or not.
The valid port number is an unsigned 16-bit integer, so 1-65535.
0 is reserved already.

Test Plan: Execute test suite

Reviewers: cedric, raster, stefan, Jaehyun_Cho

Reviewed By: raster

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5761
2018-01-25 13:23:25 +09: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
Cedric BAIL d614894d04 ecore: rename efl_loop_Eina_FutureXXX_job to efl_loop_job. 2017-12-11 14:04:09 -08:00
Carsten Haitzler 047141fc90 ecore ipc/con: fix nasty ... they dont mutually exclude
by deleting the socket they wont mutually exclude at bind which means
eny new server just nides the pror one and you can get lots of copies
of the same server. this wasnt the case before. it shouldnt have been.
i think ther was an rm path for stale sockets when connecting failed
or something. anyway... this here was causing multilpe efreetd's and
all sorts of nastiness. this is the root cause. so... fix it.

@fix
2017-11-26 14:01:14 +09:00
Cedric BAIL 871b6ac0ad ecore_con: simplify Efl.Net.Server.Ssl by inheriting from Efl.Net.Server.Tcp. 2017-09-29 16:01:02 -07:00
Cedric BAIL b7049e8c43 ecore_con: add an intermediate Efl.Net.Server.Ip 2017-09-29 14:12:03 -07:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Guilherme Iscaro ec27ceac27 efl_net: Use the new Eina_Future API. 2017-09-04 10:24:00 -03:00
Guilherme Iscaro 45a767632d Ecore_Conn: Enable CLOEXEC by default.
This flag should be enabled by default in order to avoid socket leaks.
2017-07-27 16:54:34 +02:00
Bryce Harrington 6ea18851ba ecore_con: send server_upgrade event *after* clearing pending saves
Summary:
The _ecore_con_post_event_server_upgrade() call adds an event to free
the server_upgrade object, svr, via  _ecore_con_server_free(svr) so we
should assume srv is freed after it returns.  Thus, perform the
pending_slice processing prior to calling it.  Otherwise it triggers an
illegal access (USE_AFTER_FREE) error in Coverity.

@fix CID1373485

Reviewers: barbieri

Reviewed By: barbieri

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4785

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-04-12 14:39:08 -07:00
Gustavo Sverzut Barbieri c90865ca48 ecore_con_legacy: fix legacy compatibility for ecore_con_server_send()
Since efl_net_ssl_context is immutable for a dialer and we create the
dialer with the context, the SSL cases uses a trick to postpone dialer
creation using a job, then it allows one main loop iteration for the
user to call various ecore_con_server_ssl_*() methods.

However this breaks immediate ecore_con_server_send() after
ecore_con_server_connect() as used to be allowed and used by
azy/erssd.

Most people wouldn't notice that, since the most common case is to
either use ecore_con_url (which uses cURL and a complete different
code path) OR they would wait for ECORE_CON_EVENT_SERVER_ADD prior to
sending data.

Nonetheless it was a compatibility issue and must be fixed.

Fixes T5339
2017-04-08 19:21:44 -03:00
Gustavo Sverzut Barbieri fa0e2865a1 implement efl_net_{socket,dialer,server}_windows
This is the local socket for windows, analogous to AF_UNIX.

`Efl_Net_Socket_Windows` is the base class doing `ReadFile()` and
`WriteFile()` using overlapped I/O, as well as the close procedure
(`FlushFileBuffers()`, `DisconnectNamedPipe()` and
`CloseHandle()`). These are done on top of an existing HANDLE that is
set by `Efl_Net_Dialer_Windows` (from `CreateFile()`) or
`Efl_Net_Server_Windows` (from `CreateNamedPipe()`).

The overlapped I/O will return immediately, either with operation
completed or `ERROR_IO_PENDING`, which means the kernel will execute
that asynchronously and will later `SetEvent(overlapped.hEvent)` which
is an event we wait on our main loop. That `overlapped` handle must
exist during the call lifetime, thus cannot be bound to `pd`, as we
may call `CancelIo()` but there is no guarantee the memory won't be
touched, in that case we keep the overlapped around, but without an
associated object.

Windows provides no notification "can read without blocking" or
non-blocking calls that returns partial data. The way to go is to use
these overlapped I/O, with an initial `ReadFile()` to an internal
buffer, once that operation finishes, we callback the user to says
there is something to read (`efl_io_reader_can_read_set()`) and wait
until `efl_io_reader_read()` is called to consume the available data,
then `ReadFile()` is called again to read more data to the same
internal buffer.

Likewise, there is no "can write without blocking" or non-blocking
calls that sends only partial data. The way to go is to get user bytes
in `efl_io_writer_write()` and copy them in an internal buffer, then
call `WriteFile()` on that and inform the user nothing else can be
written until that operation completes
(`efl_io_writer_can_write_set()`).

This is cumbersome since we say we "sent" stuff when we actually
didn't, it's still in our internal buffer (`pd->send.bytes`), but
nonetheless the kernel and the other peer may be adding even more
buffers, in this case we need to do a best effort to get it
delivery. A particular case is troublesome: `write() -> close()`, this
may result in `WriteFile()` pending, in this case we wait using
`GetOverlappedResult()`, *this is nasty and may block*, but it's the
only way I see to cope with such common use case.

Other operations, like ongoing `ReadFile()` or `ConnectNamedPipe()`
will be canceled using `CancelIo()`.

Q: Why no I/O Completion Port (IOCP) was used? Why no
   CreateThreadpoolIo()? These perform much better!

A: These will call back from secondary threads, but in EFL we must
   report back to the user in order to process incoming data or get
   more data to send. That is, we serialize everything to the main
   thread, making it impossible to use the benefits of IOCP and
   similar such as CreateThreadpoolIo(). Since we'd need to wakeup the
   main thread anyways, using `OVERLAPPED.hEvent` with
   `ecore_main_win32_handler_add()` does the job as we expect.

Thanks to Vincent Torri (vtorri) for his help getting this code done
with an example on how to do the NamedPipe handling on Windows.
2017-03-29 12:44:19 -03:00
Cedric BAIL deb6f0d2cd ecore_con: avoid potential crash during shutdown due to Ecore_Event queue. 2017-03-09 16:17:58 -08:00
Gustavo Sverzut Barbieri b00ea12e8b ecore_con_legacy: fix compatibility behavior (eos-mark on receiver done).
While a socket can be closed to receive data resulting in EOS, it
could still be used to send stuff. Then it won't result in "finished",
just "read,finished" event.

However, previously this was considered a disconnect and we must
respect this otherwise tests (Ecore_Con_Eet suite) will hang waiting
for a disconnect.
2016-12-20 10:18:33 -02:00
Gustavo Sverzut Barbieri 25a9e1d886 Efl.Io.{Queue,Buffer,Buffered_Stream}: slice_get is now a property.
Previously we couldn't return a slice, instead required the user to
pass a slice and we'd fill it since Eolian couldn't generate fallbacks
for structures.

Since @q66 fixed eolian, we can now return the structure itself as
initially wanted, ditching some TODO from the code.
2016-12-19 15:30:56 -02:00
Gustavo Sverzut Barbieri a7657e821f ecore_con/ecore_ipc: flush should wait for connection.
Some applications will create the handle, immediately send data, flush
and delete it, expecting the data to be sent to remote peer.

This is a bad behavior as the application would become unresponsive
until the connection is established, data can be written (since
depends on server consuming it), then allow it to be closed.

A proper behavior here would be to chain based on events, with the
usage of a copier would be simply wait for "done" event.

However the legacy API allowed this and terminology depends on this
awkward "feature", thus be bug-compatible.

This fixes T5015.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri ae054e6c0b ecore_con/ecore_ipc legacy: fail early for local sockets.
In the old/legacy API the socket would be opened early in non-blocking
mode (connect returned errno==EINPROGRESS), with UNIX socket being
path-validated early and returning NULL as 'server' handle.

Some applications relied on this instead of monitoring the "ERROR"
events, considering the connection to be successful if there was a
handle -- this was the case with Terminology after it moved from DBus
to Ecore_Ipc.

Although this is not correct, we must keep compatibility and thus we
stat() in compatibility layer, failing early as the old API would do.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri c1b20aa1fb ecore_con_legacy: fix coverity issues (use after free)
for hard failures (highly unlikely), the handle would be deleted and
the next use would crash.

guard against those or reorder when it makes sense.
2016-12-12 13:17:40 -02:00
Gustavo Sverzut Barbieri 21759f713a yoda-style inactivity timeout.
s/inactivity_timeout/timeout_inactivity/g so it matches the EFL names
with scope first, like timeout_connect, etc.
2016-12-12 02:30:33 -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 f4306d654d ecore_con: Ecore_Con_Server now on top of Efl_Net!
This is a major work and unfortunately couldn't be split into smaller
pieces as old code was highly coupled.

Ecore_Con_Server is now a wrapper around Efl_Net_Dialer_Simple
(ecore_con_server_connect()) and Efl_Net_Server_Simple
(ecore_con_server_add()), doing all that the original version did with
some fixes so ecore_con_ssl_server_upgrade() and
ecore_con_ssl_client_upgrade() are more usable -- see the examples and
-t/--type=tcp+ssl.

I tried to be bug-compatible, with code annotations where things
doesn't make sense. This was based on ecore_con_suite tests and some
manual experimenting with the examples, these can be helpful if you
find regressions (report/assign to me).
2016-12-10 08:44:06 -02:00
Jean-Philippe Andre 28c917836c efl: Cleanup some code (return values)
This removes some useless code in various places, where the
switch from eo_do() to standard function call was not properly
refactored.

This changes:

type ret = 0;
ret = my_eo_function();
return ret;

To:

return my_eo_function();
2016-08-05 10:32:30 +09:00
Tom Hacohen f21ade6123 Automatic migration to Eo4.
I just ran my script (email to follow) to migrate all of the EFL
automatically. This commit is *only* the automatic conversion, so it can
be easily reverted and re-run.
2016-03-03 09:58:08 +00:00
Srivardhan Hebbar 183cef932e ecore_con: changed Ecore_Con_Url to Efl_Network_Url.
Summary: This is just the beginning. I tried for one class to check.
Tell me if this is fine, I'll change in other classes also. The goal
is to simplify and make our API clearer to understand to new comers.

Reviewers: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2468

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-05-18 11:36:16 +02:00