By default all Pthread are cancellable. This leads to strange behavior that
happen during shutdown and hasn't been figured out. Most likely fix for T6622.
Eina Debug is a new layer aimed for EFL debugging. It offers scalability
by allowing registration of operations not specific to EFL core.
The protocol is simple and the APIs try to provide as much
functionalities/freedom as possible.
Seems to me there is little benefit of inlining this function, but this
also had a pervert effect on Windows and C++ with some recent mingw
versions. Mingw failed its implementation of pthread_cleanup_pop(). It
does not compile when compiled in C++. There is a type mismatch that is
caught by the compiler, and everything goes nuts...
This made the EFL build fail because some files of ecore_win32 are C++
sources, and they require Eina... so this macro appears in a C++ code
indirectly, because of its inlining.
By removing the inlining, this build issue is fixed. Will also fix
builds of other programs that would have used Eina.h in their C++
programs :)
CPUs can be turned off after boot leading to a sparse mapping of core ids.
For example, if I turn off the first four cores on an exynos 5422 (these
are the low speed cores) then the high speed cores are still numbered 4-7
but there are only 4 cores present.
In that situation using affinity_core % num_cpus will prevent ever being
able to set affinity at all.
Just remove the pointless check and let the user set whatever core id they
want.
As discussed in the mailing list, many people will use worker threads
to execute blocking syscalls and mandating ecore_thread_check() for
voluntary preemption reduces the ecore_thread usefulness a lot.
A clear example is ecore_con usage of connect() and getaddrinfo() in
threads. If the connect timeout expires, the thread will be cancelled,
but it was blocked on syscalls and they will hang around for long
time. If the application exits, ecore will print an error saying it
can SEGV.
Then enable access to pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)
via eina_thread_cancellable_set(EINA_TRUE), to pthread_cancel() via
eina_thread_cancel(), to pthread_cleanup_push()/pthread_cleanup_pop()
via EINA_THREAD_CLEANUP_PUSH()/EINA_THREAD_CLEANUP_POP() and so on.
Ecore threads will enforce non-cancellable threads on its own code,
but the user may decide to enable that and allow cancellation, that's
not an issue since ecore_thread now plays well and use cleanup
functions.
Ecore con connect/resolve make use of that and enable cancellable
state, efl_net_dialer_tcp benefits a lot from that.
A good comparison of the benefit is to run:
./src/examples/ecore/efl_io_copier_example tcp://google.com:1234 :stdout:
before and after. It will timeout after 30s and with this patch the
thread is gone, no ecore error is printed about possible SEGV.
so. on linux signals are delivered to the main process thread/loop.
thats' where signal handlers are set up and always run. this is sane.
it's predicatble. but of course this is not the same in bsd land.
there "just send the signal to any old thread and call the signal
handler there" seems to tbe the order of the day. this explains why
wer are losing sigchld signals in edje_cc - it's heavily threaded and
bsd is just randombly picking a thread to call it on.
this fixes that. in theory. i hope. i can't test, but putting it in to
share
@fix
DragonFlyBSD has pthread_setname_np but no pthread_setaffinity_np;
we still need to include pthread_np though.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
added support to set thread names for debugging. this wraps the gnu
extension to set a thread name of up to 15 chars (16 inc nul byte).
eina_thread_name_set() is the new api.
@feature
in the process i found the autofoo wasnt enabling cpu affinity support
at all in reality, so i had to fix that at the same time.
this makes eina_log give bt's for all error logs. this is very useful
in finding just where a problem happens. the problem int he past is
that these have not been too useful due to backtrace_symbols() being
"useless". thus use the eina_btlog tool i added too.
also started infra for a debug monitor that can use the backtrace
infra to collect runtime stats ANY TIME for a process (don't need to
run under a debugger).
@feat
Summary:
delete_cb is called at thread exit for each Eina_TLS keys used by the thread
Details:
posix:
pthread_key_create(key, delete_cb); does it
win32/wince:
eina_tls_free/new un/registers key&&cb into a static eina_list.
eina_tls_set add the key to an eina_list in Eina_Thread_Win3.
this list is cleared and callbacks are called in _eina_thread_join()
Test Plan: win32/wince has to be tested, I have no setup to do it.
Reviewers: cedric
CC: cedric
Differential Revision: https://phab.enlightenment.org/D489
eina_thread_join() is nasty and didn't report errors :-(
I'm using Eina_Error here, but it's global to the application and not
thread-local. Maybe we should make eina_error_get() and
eina_error_set() thread-local storage?
SVN revision: 81936
It's not working yet:
* eina_thread.c:152:33: error: 'index' undeclared (first use in this function)
* eina_thread.c:295:4: warning: passing argument 3 of '_eina_thread_win32_create' from incompatible pointer type [enabled by default]
also:
* line 142, is it normal that we call eina_list_append() with tw being NULL ?
* is what I did in the close_thread label correct ?
SVN revision: 78416