Commit Graph

63 Commits

Author SHA1 Message Date
Felipe Magno de Almeida 1984a1a2fb ecore_ipc: Rename EAPI macro to ECORE_IPC_API in Ecore IPC library
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.

EAPI was designed to be able to pass
```__attribute__ ((visibility ("default")))``` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.

MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.

For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.

With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).

Example 1:
dll1:
```
EAPI void foo(void);

EAPI void bar()
{
  foo();
}
```
dll2:
```
EAPI void foo()
{
  printf ("foo\n");
}
```

This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
```__atttribute__((visibility("default")))```.

However, the following:
Example 2:

dll1:

```
EAPI extern int foo;
EAPI void foobar(void);

EAPI void bar()
{
  foo = 5;
  foobar();
}
```

dll2:

```
EAPI int foo = 0;
EAPI void foobar()
{
  printf ("foo %d\n", foo);
}
```

This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.

Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-10-26 13:31:38 -03:00
Yeongjong Lee 4e24854f46 ecore_ipc: remove duplicated condition
The same condition is used above.

Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Differential Revision: https://phab.enlightenment.org/D12077
2020-07-31 10:14:00 +02:00
Elyes HAOUAS 1fd0435f21 Get rid of trailing whitespaces (4 / 14)
Remove trailing whitespaces
Differential Revision: https://phab.enlightenment.org/D12002
2020-06-23 10:29:14 +02:00
Subhransu Mohanty a02deffad7 ecore_ipc: Fix memory leak
Summary:
As delete_me flag was not updated in the delete callback it dosen't
call ecore_ipc_client_del() on the client hence the leak.

Reviewers: Hermet, raster, bu5hm4n, CHAN

Reviewed By: Hermet, CHAN

Subscribers: CHAN, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11927
2020-06-08 20:27:42 +09:00
Hosang Kim 020a59b0f2 ecore_ipc: close dialer io closer when dialer is deleted.
Summary:
dialer uses copier class, so dialer's close on invalidate flag is EINA_FALSE.
Therefore dialer io closer is not closed automatically.

Reviewers: barbieri, raster, Hermet, zmike

Reviewed By: zmike

Subscribers: zmike, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8922
2019-05-22 08:01:58 -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
Vincent Torri f7c560c311 replace hton and ntoh family functions with ones defined in eina
Summary: This fixes especially the execution of edje_cc on Windows

Test Plan: execution of edje_cc

Reviewers: cedric, raster

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7834
2019-02-01 14:25:35 +00: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 86c855bdd3 ecore ipc - fix send to skip data payload if null/0
conversion to efl.nmet didnt deal with null/0 zised payloads properly
and tried to send them, resulting in lots of ERR complaints which were
not errors. fix that to not try and send such empty payloads

@fix
2018-04-11 14:34:40 +09:00
Carsten Haitzler fd6d9da8fa ecore ipc - fix flush to not lose messages
it wasn't looking at the copier queue "todo" at all thus skipping it
on flush. this will fix flushing of ecore ipc message buffers. this
happens to also now fix terminology's "one process" mode.

@fix
2018-03-26 23:17:56 +09: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
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
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
Jean-Philippe Andre f839905184 ecore_ipc: Unregister log domain on shutdown
An old comment mentioned that this was explicitely not unregistered, but
I believe the comment isn't valid since ecore_event_type_flush() was
introduced.
2017-09-26 17:58:07 +09: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
Guilherme Iscaro 97f6803be1 Ecore_IPC: Preserve Ecore_Con legacy behaviour.
This patch sets some Ecore_Con flags that were missing after
the EO migration. These flags must be set in order
maintain the Ecore_IPC behaviour before Ecore_Con EO was implemented.

Fixes T5722
2017-07-27 16:54:16 +02:00
Mike Blumenkrantz f2edb935a4 ecore-ipc: don't return dead clients in ecore_ipc_server_clients_get
@fix

fix T5383
2017-06-09 19:14:59 -04:00
Gustavo Sverzut Barbieri 6877ee8ad4 ecore_ipc: use new efl_net_*_windows classes. 2017-03-29 12:44:19 -03:00
Cedric BAIL 988344f3e5 ecore_ipc: avoid crash during shutdown due to Ecore_Event queue. 2017-03-09 16:17:58 -08: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 482437ee14 ecore_con/ecore_ipc: keep log domain alive after shutdown.
These legacy API had the nasty behavior of keeping handles alive until
the pending events were dispatched, this could happen after the module
itself was shutdown, resulting in log to unregistered domains.

Then do not unregister the domain -- eina_shutdown will avoid leaks
anyway.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri 4812d9eb74 add missing includes for BSD.
Thanks @netstar.
2016-12-12 12:17:11 -02:00
Stefan Schmidt 12fccd1d3c ecore_ipc: silence a maybe unitialized warning
I always got this during the build:
lib/ecore_ipc/ecore_ipc.c:537:6: warning: ‘old_mask’ may be used uninitialized in this function
[-Wmaybe-uninitialized]

Looking at the code it really is a false positive. Gettign the mask is behind
an if it is the same if condistion used before writing it. Anyway, silencing the
warning here.
2016-12-02 16:28:31 +01:00
Gustavo Sverzut Barbieri 48049a4ce2 efl_net_server_unix: add leading_directories_create property.
This allows us to crete any parent directories that are missing.
2016-11-25 18:01:29 -02:00
Gustavo Sverzut Barbieri 16be61c7e1 efl_io_copier_flush: add may_block and ignore_line_delimiter parameters.
The may_block parameter is useful to force a flush without blocking on
read/write, sometimes particularly useful if ignore_line_delimiter is
true, then you get the data events without blocking -- as if a server
sending some content misses a trailing line delimiter, you do not want
to block on recv() but still want to flush data to user.

The ignore_line_delimiter parameter is useful if we're going to close
the copier and want to flush pending data which may exist due missing
trailing terminator. The close method will also force that if
destination can take more data.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri 9805f4ec36 ecore_ipc: isolate legacy within ifdefs.
Compile out the legacy code when running on platforms that support
Efl.Net.Dialer.Unix and Efl.Net.Server.Unix.
2016-11-23 22:35:48 -02:00
Gustavo Sverzut Barbieri 400f3932d9 ecore_ipc: fix user after free in error handling.
Fixes Coverity 1366274.
2016-11-23 22:15:25 -02:00
Gustavo Sverzut Barbieri 6f3220ffc6 ecore_ipc: convert ecore_ipc_server_add() to Efl_Net_Server.
Each client (Ecore_Ipc_Client) is very similar to the handle
configured by ecore_ipc_server_connect() (the dialer), except we do
not have events such as "connected" and "error", as well as we don't
delete the socket as it's owned by the server, instead we close it.

The UNIX socket is configured similarly to ecore_con, setting the same
masks and mode for directories.
2016-11-23 19:45:33 -02:00
Gustavo Sverzut Barbieri fc76abccd6 ecore_ipc: free(address) on dialer error. 2016-11-23 18:22:21 -02:00
Gustavo Sverzut Barbieri 768e6498b1 ecore_ipc: dialers should use max_buf_size = -1.
nothing appears to break, but let's use the same value as legacy.
2016-11-23 17:38:18 -02:00
Gustavo Sverzut Barbieri 3131a966c9 ecore_ipc: rename 'server' to 'legacy_server'.
Since the plan is to introduce a server based on efl_net_server, first
rename the existing handle with 'legacy_' prefix.
2016-11-23 17:09:18 -02:00
Gustavo Sverzut Barbieri e34b07e6e2 ecore_ipc: implement ecore_con_server_connect() using Efl.Net.Dialer.
Use the new Efl.Net.Dialer classes to implement
ecore_con_server_connect() scenario.

Note that since Windows still doesn't provide any equivalent to
Efl.Net.Dialer.Unix, we keep the legacy code for it.
2016-11-23 12:57:10 -02:00
Gustavo Sverzut Barbieri 715c882073 ecore_ipc: check if client is still alive efore emitting 'del' event.
Using the ecore_ipc_server_example with -m/--single-message, if we
deleted the client from the callback it would find a dead "cl".

As the "cl" handle is removed from svr->clients before it's deleted,
it's safe to check if we have that handle in the list before
proceeding.
2016-11-23 12:57:10 -02:00
Gustavo Sverzut Barbieri e6939ebc90 ecore_ipc: refactor client data processing in its own function.
When we move to efl_net we'll reuse the same function to process
incoming data, thus refactor the code in their own function so it can
be reused.
2016-11-23 00:01:14 -02:00
Gustavo Sverzut Barbieri 520b57e974 ecore_ipc: refactor server data processing in its own function.
When we move to efl_net we'll reuse the same function to process
incoming data, thus refactor the code in their own function so it can
be reused.
2016-11-22 23:55:57 -02:00
Gustavo Sverzut Barbieri 89c326cd00 ecore_ipc: refactor code related to event posting.
When we move to efl_net we'll reuse the same event posting, thus
refactor the code in their own function so it can be reused.
2016-11-22 23:20:40 -02:00
Gustavo Sverzut Barbieri 915034b9e0 ecore_ipc: fix copy & paste error. 2016-11-22 23:20:22 -02:00
Gustavo Sverzut Barbieri 53f1c1ca6e ecore_ipc: delete if 'delete_me' was set.
The flag 'delete_me' is set when there are pending events to be
dispatched. Once these events are freed, they will check if the server
was pending delete and call ecore_ipc_server_del() again, thus we must
not return, otherwise data will be leaked.
2016-11-22 19:53:06 -02:00
Gustavo Sverzut Barbieri 54ca7db20b ecore_ipc: remove unused headers. 2016-11-22 19:50:11 -02:00
Gustavo Sverzut Barbieri 302cf36722 ecore_ipc: log domain can be static, it's not shared with other files. 2016-11-22 19:50:11 -02:00
Jee-Yong Um 3b4293ffa3 ecore_file/ipc: clean up documentation
Summary: move comment from c source to header and adjust ingroup relationship

Reviewers: cedric, jpeg, Hermet

Reviewed By: Hermet

Differential Revision: https://phab.enlightenment.org/D4328
2016-10-04 21:08:17 +09:00
Prince Kumar Dubey 8fbb6dbbbb If there is situation when server is closed prior to client, the client pointer pointing to server must be reset and check must be there during client deletion
Summary: During mobile product testing, we got a crash with callstack which suggest server is getting deleted prior to client. On valgrind analysis we found invalid write operation with same callstack. callstack is pasted in comment section.

Test Plan: create a situation where server got deleted prior to client.

Reviewers: raster, cedric

Subscribers: govi, rajeshps, jpeg

Differential Revision: https://phab.enlightenment.org/D4152
2016-07-11 22:29:04 +09:00
Amitesh Singh bab9cb7bed ecore_ipc: fix typo in ecore_ipc_server_send() API doc 2015-10-02 01:23:13 +05:30
Thiep Ha 88b2bfe435 ecore_ipc: remove redundant code
Summary:
buf is always NULL (already freed and set to NULL).
We don't need to add NULL checking and free it.

Reviewers: raster, cedric, Hermet

Subscribers: seoz, cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-07-28 03:05:37 +02:00
Shinwoo Kim 4c1b5a5e30 ecore_ipc: coverity issue - you cannot return without free
Summary: The allocated memory is not released before return.

Lost track of the CID.

Test Plan: Run static analysis tool such as prevent

Reviewers: raster, cedric

Reviewed By: cedric

Subscribers: cedric, seoz

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2014-12-12 04:05:40 +01:00
Cedric Bail 403e97ecb0 ecore_ipc: prevent a double free.
According to clang static analyzer it is possible to find a path where
buf and svr->buf are pointing to the same array, better be safe than sorry.
Arguably this code could be more readable if it was using Eina_Binbuf.
2013-11-28 17:17:09 +09:00