Commit Graph

32 Commits

Author SHA1 Message Date
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
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
Andy Williams d5dbcdabd1 eo: Rename efl_ref_get to efl_ref_count 2017-11-08 09:30:42 +00:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05: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
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
Gustavo Sverzut Barbieri 9486225744 ecore_con: remove warnings if FD_CLOEXEC is undefined.
currently it's being defined in evil_fcntl.h, but the actual
implementation of fcntl() in evil_fcntl.c is causing problems with
sockets. So one possibility is to remove the ifdef, another is to
change the implementation.
2017-03-29 12:44:19 -03:00
Gustavo Sverzut Barbieri fb0e716c1a efl_net: fix formatting warnings from windows. 2016-12-09 19:33:40 -02:00
Gustavo Sverzut Barbieri 410d65900c efl_net_server: add 'client_announce', share logic and fix a bug.
I just realized that if a client is not referenced it would leak in
the 'ssl' server as we must del it.

However, if we del the SSL socket, we're going to close the underlying
TCP. But we're from the TCP "client,add" callback and this causes
issues since "closed" will be emitted, our close callback will
unparent the client, which lead to it being deleted.

The proper solution is to only monitor "closed" if the client is
accepted. Otherwise we just check if it was closed, if we're the
parent, etc...

Fixing this in all servers were painful, we could share since most
inherit from Efl.Net.Server.Fd. Then add the "client_announce"
protected method to do it, and document how it should work.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri 92a3361deb efl_net_server_fd: do not spin if clients can be accepted.
If we have incoming clients but we do not want to drop or handle then,
stop monitoring the fd's read, otherwise we constantly spin the main
loop.
2016-11-24 00:42:54 -02:00
Gustavo Sverzut Barbieri dc3da201fd efl_net: remove warnings related to unused parameters.
if these options are not available, then cast "o" to void so it
doesn't trigger a warning, for example on Windows.
2016-11-18 14:21:21 -02:00
Gustavo Sverzut Barbieri 371a3332ef efl_net: remove getsockopt()/setsockopt() warning on windows.
windows is nasty and defines the value to be set or retrieved as
'char *', which triggers a warning when we use another kind of
pointer.

Partially addresses D4357.
2016-11-18 12:53: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 c2630c829f efl_net_server support systemd socket activation.
It includes extensive verifications to avoid mistakes and usage of
incorrect sockets.
2016-11-01 16:37:04 -02:00
Gustavo Sverzut Barbieri 1ea6a42f7a remove incorrect EINA_UNUSED. 2016-10-31 19:38:22 -02:00
Gustavo Sverzut Barbieri 91499c5179 efl_net_server_fd: fix inverted comparison for valid socket handle. 2016-10-22 22:41:01 -02:00
Gustavo Sverzut Barbieri 5517c9b261 efl_net_server_fd: close socket on destructor. 2016-10-22 22:26:02 -02:00
Gustavo Sverzut Barbieri 00fa8a8cc7 efl_net_*: fix some more Win32-unfriendly code. 2016-10-22 22:14:45 -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 9c0ce3946a efl_net_server_fd: one more WIN32 friendly comparison.
with the fallback define, it's valid on POSIX and Windows.
2016-10-22 21:20:56 -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
Gustavo Sverzut Barbieri f57316655c efl_net_server_fd: allows custom socket 'read' event handling.
This allows UDP to reimplement it using recvfrom() instead of
accept().
2016-10-21 13:33:27 -02:00
Gustavo Sverzut Barbieri 72bfca0df5 efl_net_server_fd: fix coverity issue.
fixes CID 1361945, minor but let's do it :-)
2016-09-05 09:36:14 -03:00
Jiwon Kim b52725cef5 efl_net: check definition 'SO_REUSEPORT' for port reuse flag
Summary:
The port reuse feature and 'SO_REUSEPORT' flag are not supported by a few linux
In case of linux kernel, it supported from v 3.9
  (https://kernelnewbies.org/Linux_3.9)
On the lower version of kernel, compile is failed

Reviewers: barbieri, jayji

Reviewed By: jayji

Subscribers: akanad, id213sin, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4256
2016-09-01 19:08:25 +02: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
Vitor Sousa 8356b16a49 Efl Object: remove legacy callback calls from event_callback_call
Efl.Object.event_callback_call no longer calls legacy smart callbacks;
calling only event callbacks registered with the given event description
pointer.

Create the method Efl.Object.event_callback_legacy_call to inherit the old
behavior from Efl.Object.event_callback_call, calling both Efl.Object events
and legacy smart callbacks.

Update all other files accordingly in order to still supply legacy
callbacks while they are necessary.
2016-08-26 15:45:07 -03:00
Gustavo Sverzut Barbieri e3ee477140 efl_net: better handling for SOCK_CLOEXEC.
On systems where SOCK_CLOEXEC is supported, give it to socket() and if
accept4() is supported, then use it as well.

Otherwise revert to fcntl().
2016-08-24 12:34:59 -03:00
Gustavo Sverzut Barbieri 164d9ddfde Revert "ecore_con: use F_CLOEXEC instead of SOCK_CLOEXEC"
This reverts commit 99d37838f3.

will be fixed in a better way with the following commit.
2016-08-24 12:02:17 -03:00
Jean Guyomarc'h 99d37838f3 ecore_con: use F_CLOEXEC instead of SOCK_CLOEXEC
Mac OS X does not provide SOCK_CLOEXEC. Instead, we can use
fcntl() with F_CLOEXEC.
Fixes Mac OS X build.
2016-08-23 21:15:16 +02:00
Gustavo Sverzut Barbieri e7df1a7483 efl.net: socket, server and dialer for TCP.
Efl.Net.Server defines how to accept new connections, doing the
bind(), listen() and accept() for protocols such as TCP.

Efl.Net.Dialer defines to to reach a server.

Both are based on Efl.Net.Socket as communication interface that is
based on Efl.Io.Reader, Efl.Io.Writer and Efl.Io.Closer, thus being
usable with code such as Efl.Io.Copier.

The Server will emit an event "client,add" with the established
Socket, which is a child and can be closed by both the server or the
user.

The Dialer extends the Socket and allows for creating one given an
address, that will be resolved and connected.

TCP is the initial implementation so we an validate the
interfaces. UDP, Unix-Local and SSL will come later as derivate
classes.

The examples are documented and should cover the basic principles:

 - efl_io_copier_example can accept "tcp://IP:PORT" and will work as a
   "netcat", can send data from socket, file or stdin to a socket,
   file, stdout or stderr.

 - efl_net_server_example listens for connections and can either reply
   "Hello World!" and take some data or work as an echo-server,
   looping back all received data to the user.

More complex interactions that require a "chat" between client and
server will be covered with new classes later, such as a queue that
empties itself once data is read.
2016-08-22 18:25:14 -03:00