Commit Graph

185 Commits

Author SHA1 Message Date
Dmitri Chudinov 472cee52b2 ecore: solve error with gsource = null
Compiling using -Dglib=true and -Dg-mainloop=true causes glib errors every time when efreet_icon_cache_create is invoked (ex., run and stop elementary_config and observe the terminal output).

So, i added error message in place where ecore_glib_source may be undefined. The issue was with undefined ecore_glib_source variable in _ecore_main_loop_setup function. Here _ecore_main_fdh_poll_add was used before actual ecore_glib_source definition.

@fixed
2023-12-19 03:56:53 -08:00
Carsten Haitzler c493765702 ecore - fix name/ref for source of fix analysis etc. 2021-06-05 20:41:06 +01:00
Carsten Haitzler 4f5b1b2fad ecore - mainloop - select - increase max set size and check fd if over
if fd's exceed max set size then things will ... god bad. how - ...
depends on the OS but at least report that there is an issue.
2021-06-04 12:29:22 +01:00
Carsten Haitzler 39b48ca430 Revert "fix warnings about redefinting EWAPI etc. due to windows EAPI changes"
This reverts commit e2d6691d52.
This reverts commit c02b796fdb.
This reverts commit 6c969f6b7d.
This reverts commit 74204bccd7.
This reverts commit 1304d95717.
This reverts commit 7c85be9674.

revert the EAPI changes that break cxx bindings build. sorry :( more
fixes needed than i thought
2021-05-26 15:46:25 +01:00
Felipe Magno de Almeida 74204bccd7 ecore: Rename EAPI macro to ECORE_API in Ecore library
Summary:
=  The Rationale =

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>

Reviewers: vtorri, raster

Reviewed By: raster

Subscribers: raster, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12271
2021-05-23 20:47:23 +01:00
Carsten Haitzler b27a0f2b2d ecore - call freeq reduce again on idle enter...
this led to a nasty leak unless you had ilders runnig every now and
again. freeq would just epxand and expand...

@fix
2021-01-03 19:36:50 +00:00
Carsten Haitzler 6096779ede ecore - expose "hidden" internal api for debugging to get wakeup time
get the real time at which main loop woke up for purposes of debugging
and finding jank/scheduling jitter.
2020-05-23 09:34:57 +01:00
Carsten Haitzler 43f5b271e4 ecore - systemd - missed an ifdef for sytemd disable 2020-05-18 10:27:55 +01:00
Carsten Haitzler fe56edae3f systemd - make libsystemd use/supprot entirely runtime "dlopened"
so i've moved all systemd and elogind support to be runtime only with
dlopen (eina_module) of libsystemd.so.0 (or libelogind.so.0 for elput)
and finding of symbols manually at runtime (if the right code paths or
env vars are set), thus remvoing the need to decide at compile time if
efl needs systemd support or not as it no longer needs systemd
headers/libs at compile time and just at runtime. this simplifies
building a bit and makes efl more adaptive to the final target system
at runtime.
2020-05-18 09:36:55 +01:00
Carsten Haitzler 559bbd8ce3 freeq - up numbers for fq blocks and other limits to defer big batches
this should improve some perf by upping the max a free queu can baloon
up to 256k items and 32m of data (whichever is hit first).
2020-02-28 20:03:05 +00:00
Mike Blumenkrantz 36c5f1026f ecore/main: avoid calling FD_SET with invalid fd value
Summary:
it's possible that _ecore_get_epoll_fd() can return -1, so ensure that we
correctly handle this

CID 1383850

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10394
2019-10-18 13:29:01 -04:00
Mike Blumenkrantz 8c6b26af01 ecore: inhibit "idle" event emission if no subscribers exist
Summary:
it seems like this was intended to be handled already, but somehow it wasn't...

ref T8321
Depends on D10358

Reviewers: cedric

Reviewed By: cedric

Subscribers: bu5hm4n, cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8321

Differential Revision: https://phab.enlightenment.org/D10359
2019-10-14 09:30:03 -04:00
Carsten Haitzler 9b294d6284 eina file - stat generation inexactness support
this is a performance optimization. it brings in a "stat generation".
for now it's disabled by default so we retain previous behavior. this
stops eina file from opening and stating a file every time you open
... it only does it if stat generation is off, or, if the generation
changed since the last time it opened that file. this makes cache hits
not have a 3 syscall cost (open+fstat+close). this optimizes that
lower end of things path. but .. it comes at a cost. if the file
changes before generation ticks over (which this forces to tick over
every time the loop exits idle by default).

now here is something to ask.

1. should we have this on by default and accept the "inexactness"
since you can eina_file_statgen_next() before any call that would do
i/o to force it to look at the real file stat info...
2. should we tick over every idle enter OR every N idle enters  or
every frame we render instead? ... i want to avoid getting a timestamp
or having a timer interrupt often... so what should we do?

at least this introduces the idea, some api's and an env var to turn
this on. it definitely cuts down syscalls during things like creation
of widdgets or objects in large batches etc.
2019-07-28 11:51:15 +01:00
Mike Blumenkrantz 17f433c57b ecore: avoid breaking next main loop start if quit occurs outside of loop
in the case where ecore_main_loop_quit() was called before ecore_main_loop_begin(),
the latter call would exit immediately without ever iterating the main loop

@fix

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9360
2019-07-19 15:04:56 -07:00
Vincent Torri 839f22870b bin/efl and ecore: include evil_private.h when appropriate
Test Plan: compilation

Reviewers: raster, zmike, cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8908
2019-05-17 11:53:35 +01:00
Derek Foreman 66ce295fc9 ecore_main: Add ECORE_FD_ALWAYS flag
This allows an fd handler to be called after select exits unconditionally.

Our wayland client code needs this to be thread safe, as it needs to
call prepare_read before entering select, and then either read or
cancel_read after select.

Signed-off-by: Derek Foreman <derek.foreman.samsung@gmail.com>
Reviewed-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7914
2019-02-13 10:33:40 -06:00
Christopher Michael 4c587ef679 Revert this as it should not have been pushed yet
Revert "ecore_main: Add ECORE_FD_ALWAYS flag"

This reverts commit b5e90ebe0d.
2019-02-13 10:01:22 -05:00
Derek Foreman b5e90ebe0d ecore_main: Add ECORE_FD_ALWAYS flag
Summary:
This allows an fd handler to be called after select exits unconditionally.

Our wayland client code needs this to be thread safe, as it needs to
call prepare_read before entering select, and then either read or
cancel_read after select.

Reviewers: cedric

Reviewed By: cedric

Subscribers: zmike, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7914
2019-02-13 09:58:06 -05:00
Taehyub Kim d8182638f2 ecore_main: fix the invalid return value
Summary:
fix the invalid return value
@fix

Reviewers: Jaehyun_Cho, raster, Hermet

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7080
2018-09-21 14:46:50 +09:00
Mike Blumenkrantz 8e6d66450d ecore/main: only update loop_time during loop iteration if the change is monotonic
Summary:
in the case where the user has called loop_time_set with a value in the future,
avoid setting the loop time to something that would potentially cause a callback
to occur with a loop_time value before a previous occurrence of that callback

@fix

Reviewers: ManMower

Reviewed By: ManMower

Subscribers: ManMower, #reviewers, cedric, #committers

Tags: #efl_main_loop

Differential Revision: https://phab.enlightenment.org/D6764
2018-08-14 17:09:32 -04:00
Alastair Poole b00f0e0630 ecore_main: silence warning when compiling.
Summary:
Silence compilation warning.
There is an ifdef'd block of code which accesses obj but
I don't think it's in use in production?

Test Plan: Build EFL and watch for warning.

Reviewers: #committers, zmike, Hermet

Reviewed By: #committers, Hermet

Subscribers: cedric

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6628
2018-07-19 15:53:49 +09:00
Thierry HUCHARD 65da58726f ecore/main: fix build with --enable-g-main-loop
this resolves compiler errors with this option which resulted from refactoring

fix T7011
2018-06-22 17:42:22 -04:00
Cedric BAIL c49d293915 ecore: allow for NULL file handler request. 2018-05-24 16:02:20 -07:00
Cedric BAIL f7b08c4537 ecore: properly cleanup variable on shutdown, so that cycling another init doesn't crash. 2018-05-24 16:02:20 -07:00
Cedric Bail a16d127997 ecore: because fd_handler do not have the main loop as parent, the main loop can die before them. 2018-05-24 16:02:19 -07:00
Cedric BAIL cdbbaede7e efl: remove old Efl_Future, Efl_Promise. 2018-05-01 10:39:01 -07:00
Cedric BAIL 7019b8857b ecore: don't artificially block fonctionnality for nested loop.
We do have nested loop when manually calling iterate and was used
in legacy code that got broken with this change.
2018-04-30 14:21:11 -07:00
Daniel Zaoui 9cbba2d0b4 Fix exit code setting for legacy applications
The value must be given to eina_value_set and not a pointer to a
Eina_Value.
This bug results in always getting wrong exit code when the application
terminates.
2018-04-22 15:44:41 +03:00
Shinwoo Kim 3cd2243028 Fix static analysis result
[Dereference after null check]

(1) src/lib/ecore/ecore_main.c
 - _efl_loop_handler_efl_object_finalize checks if pd->loop_data is NULL.
   After that, _handler_reset > _handler_clear > _ecore_main_fd_handler_del >
   _ecore_main_fdh_pool_del is directly dereferencing pd->pool_data.
 - _efl_loop_handler_efl_object_parent_set checks if pd->loop_data as well.
   Then it calls _handler_reset as well.

(2) src/lib/ecore_wayland/ecore_wl_dnd.c
  - ecore_wl_dnd_selection_set checks if t - result of wl_array_add - is NULL.
    And it is dereferecing t directly for wl_data_source_offer.

(3) src/lib/elementary/efl_ui_dnd.c
 - Third parameter const char *data could be NULL.
   In this case strlen dereferences NULL. The data should be non NULL value.
   I have checked this with Mr. Thiep Ha.

(4) src/lib/evas/canvas/evas_object_inform.c
 - _efl_canvas_object_efl_gfx_stack_stack_below checks if obj->layer is NULL.
   So it could call evas_object_inform_call_call_restack which is dereferencing
   obj->layer directly.
2018-04-05 19:40:57 +09:00
Cedric Bail c3c5620c1c ecore: the main loop has no parent and only one ref, let's properly create it. 2018-03-19 15:33:11 -07:00
Carsten Haitzler 1bdd9e4dd1 ecore - a different take on efl.app class as a super class to efl.loop
so the MAIN loop is actually an efl.app object. which inherits from
efl.loop. the idea is that other loops in threads will not be efl.app
objects. thread on the creator side return an efl.thread object.
inside the thread, like the mainloop, there is now an efl.appthread
object that is for all non-main-loop threads.

every thread (main loop or child) when it spawns a thread is the
parent. there are i/o pipes from parnet to child and back. so parents
are generally expected to, if they want to talk to child thread, so
use the efl.io interfaces on efl.thread, and the main loop's elf.app
class allows you to talk to stdio back to the parent process like the
efl.appthread does the same using the efl.io interfaces to talk to its
parent app or appthread. it's symmetrical

no tests here - sure. i have been holding off on tests until things
settle. that's why i haven't done them yet. those will come back in a
subsequent commit

for really quick examples on using this see:

https://phab.enlightenment.org/F2983118
https://phab.enlightenment.org/F2983142

they are just my test code for this.

Please see this design document:

https://phab.enlightenment.org/w/efl-loops-threads/
2018-03-03 13:40:33 +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 d262ff447e ecore - fd handler - dont set legacy flag on null fdhandlers
now passes make check again.
2018-02-21 19:05:48 +09:00
Carsten Haitzler 8c62e2a817 ecore - fd handlers - only delete legacy eo objects in handlers
if its a non-legacy loop handler that also binds an fd handler
internally (the 2 things are linked as a pair) then on loop del, dont
del the objet as the obj del should handle things elsehwere.
2018-02-21 16:56:38 +09:00
Carsten Haitzler 468b2b380c ecore - fix fd handlers to also set read/write/err flags on hup's
odd - i found ecore fd handlers basically ignored hangups from the
other end so we never knew if the other end went or not... crazy. now
we at least have all the read/write/error flags on and the next read
should fail indicating the broken pipe etc. ...

@fix
2018-02-21 16:56:38 +09:00
Myoungwoon Roy, Kim e9d1a1e988 ecore_main: Check for the valid flag
Summary:
This patch checks for the valid Ecore_Fd_Handler_Flags.
The flags should be checked like previous verion because
There are no default handlings in case of out of Ecore_Fd_Handler enum values in other funcs.

Test Plan: Execute a test case

Reviewers: cedric, raster, jpeg, stefan, Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D5775
2018-01-31 18:55:40 +09:00
Myoungwoon Roy, Kim 0a5b15ccac ecore_main: Check for null ptr deref
Summary: This patch fixes a tentative crash owing to dereference of fd_handler.

Test Plan: Execute test suite

Reviewers: cedric, raster, stefan, Jaehyun_Cho

Reviewed By: Jaehyun_Cho

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5754
2018-01-22 21:27:20 +09:00
Vincent Torri 4ae6eeb2cf efl: remove _MSC_VER (Visual Studio macro) usage in source code 2018-01-04 12:59:47 -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
Carsten Haitzler 27ac9a2be2 ecore main loop - fix fd handler clearning
so loop object destruction was clearing out fd handlers but those may
be later deleted by destructors of child objects. so leave legacy
fdh's and just remove them from the list
2017-12-23 21:13:47 +09:00
Carsten Haitzler 6b70cd5f97 ecore/efl loop - refactor idle stuff to be less convluted when
less jumping around the codebase and no need for a message exists
method on the loop as we can find out internally, so only the process
left.
2017-12-21 19:45:21 +09:00
Cedric BAIL 90f30ea418 eina: make __eina_promise_cancel_all an internal only function. 2017-12-18 16:17:04 -08:00
Jean-Philippe Andre fed8123448 ecore: Avoid double free with promises 2017-12-18 19:54:31 +09:00
Jean-Philippe Andre 9427862d40 ecore: Fix clean shutdown
There is no good reason to not shutdown a library properly. The loop
object can easily be deleted safely, if it is properly initialized. The
del event happens before destruction so it is too early to set the
singleton variable to NULL. Do that as late as possible and all calls to
efl_loop_main_get() will work as expected.

The issue with fd's was simply that they were not initialized to -1
(timer_fd), as some #ifdef statements have disappeared.
2017-12-18 19:54:31 +09:00
Carsten Haitzler 679d41fc3c ecore - remove warning for win build 2017-12-17 16:27:08 +09:00
Carsten Haitzler 52c9c0e939 windows build - try fix again 2017-12-17 16:03:33 +09:00
Carsten Haitzler 4abe5d90e4 ecore main - try fix windows build
i hope this fixes T6517
2017-12-17 15:07:37 +09:00
Carsten Haitzler 02737b1308 ecore - unify comment style 2017-12-15 14:36:30 +09:00
Carsten Haitzler 5dd52fd09b ecore - begin moving data into the efl loop data in the object
we really should have data inside the loop object, so begin moving it
one small thing at a time. this is the basics that will allow multiple
efl loops. make an eo efl object and class for fd handlers that is efl loop
bound make fd handlers really bound to their parent loop and not global  as
well as have a nice class/obj. create an message queue per loop and
put legacy ecore events on top of it... and a lot more.

this is not 100% done, but it's a lot of the core and groundwork.
various ecore_timer_add(), ecore_diler_add() etc. need changes.

The following still need doing:

  ecore_timer (internal usage for sure)
  ecore_idler (internal usage for sure)
  ecore_idle_enterer
  ecore_idle_exiter
  ecore_pollers? (is the new efl loop stuff ok?)
  ecore_exe (fork/spawn from any thread and track exe from that thread?)
  ecore_signal code
  ecore_throttle (should we have a single global too? we have per loop)
  ecore_app ? (should every loop be given its own argv/argc?)

Lots of internal ecore code uses/calls these legacy calls and we
should have efl loop replacements and/or use the ones we have

The following will bedifferently designed for loop to loop
control/messaging/ipc:

  ecore_thread
  ecore_pipe
2017-12-15 14:16:53 +09:00