forked from enlightenment/efl
Ecore: fix seg fault in ecore_thread on Windows
PHS() was returning a wrong value. Thanks to Cedric for the help SVN revision: 75720
This commit is contained in:
parent
3faee27bd8
commit
b20f37ef58
|
@ -870,3 +870,8 @@
|
||||||
|
|
||||||
* Add ecore_x custom blanker screensaver enable/disable - cant
|
* Add ecore_x custom blanker screensaver enable/disable - cant
|
||||||
do e17 properly without so add in even in freeze.
|
do e17 properly without so add in even in freeze.
|
||||||
|
|
||||||
|
2012-08-27 Vincent Torri
|
||||||
|
|
||||||
|
* Fix segmentation fault in ecore_thread on Windows as PHS
|
||||||
|
was returning a wrong value.
|
||||||
|
|
|
@ -30,6 +30,7 @@ Fixes:
|
||||||
- Make Ecore_Thread work reliably when called without a running main loop.
|
- Make Ecore_Thread work reliably when called without a running main loop.
|
||||||
- Correctly shutdown Ecore_Thread.
|
- Correctly shutdown Ecore_Thread.
|
||||||
- Fix usage of FD_SET and al. when fd_set pointers are NULL (Windows)
|
- Fix usage of FD_SET and al. when fd_set pointers are NULL (Windows)
|
||||||
|
- Fix ecore_thread seg fault on Windows where PHS() was returning a wrong value
|
||||||
|
|
||||||
* ecore_x
|
* ecore_x
|
||||||
- Fix unitialized Ecore_X_Atom use.
|
- Fix unitialized Ecore_X_Atom use.
|
||||||
|
|
|
@ -66,44 +66,79 @@ typedef struct
|
||||||
void *val;
|
void *val;
|
||||||
} win32_thread;
|
} win32_thread;
|
||||||
|
|
||||||
|
static Eina_List *_ecore_thread_win32_threads = NULL;
|
||||||
|
static Eina_Lock _ecore_thread_win32_lock;
|
||||||
|
|
||||||
# define PH(x) win32_thread * x
|
# define PH(x) win32_thread * x
|
||||||
# define PHE(x, y) ((x) == (y))
|
# define PHE(x, y) ((x) == (y))
|
||||||
# define PHS() (HANDLE)GetCurrentThreadId()
|
|
||||||
|
|
||||||
int
|
static win32_thread *
|
||||||
|
_ecore_thread_win32_self()
|
||||||
|
{
|
||||||
|
win32_thread *t;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
|
LKL(_ecore_thread_win32_lock);
|
||||||
|
EINA_LIST_FOREACH(_ecore_thread_win32_threads, l, t)
|
||||||
|
{
|
||||||
|
printf("thread self : %p %p\n", t, t->thread);
|
||||||
|
if (t->thread == GetCurrentThread())
|
||||||
|
{
|
||||||
|
LKU(_ecore_thread_win32_lock);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LKU(_ecore_thread_win32_lock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
# define PHS() _ecore_thread_win32_self()
|
||||||
|
|
||||||
|
static int
|
||||||
_ecore_thread_win32_create(win32_thread **x,
|
_ecore_thread_win32_create(win32_thread **x,
|
||||||
LPTHREAD_START_ROUTINE f,
|
LPTHREAD_START_ROUTINE f,
|
||||||
void *d)
|
void *d)
|
||||||
{
|
{
|
||||||
win32_thread *t;
|
win32_thread *t;
|
||||||
|
|
||||||
t = (win32_thread *)calloc(1, sizeof(win32_thread));
|
t = (win32_thread *)calloc(1, sizeof(win32_thread));
|
||||||
if (!t)
|
if (!t)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
LKL(_ecore_thread_win32_lock);
|
||||||
(t)->thread = CreateThread(NULL, 0, f, d, 0, NULL);
|
(t)->thread = CreateThread(NULL, 0, f, d, 0, NULL);
|
||||||
if (!t->thread)
|
if (!t->thread)
|
||||||
{
|
{
|
||||||
free(t);
|
free(t);
|
||||||
|
LKU(_ecore_thread_win32_lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
t->val = d;
|
t->val = d;
|
||||||
*x = t;
|
*x = t;
|
||||||
|
_ecore_thread_win32_threads = eina_list_append(_ecore_thread_win32_threads, t);
|
||||||
|
LKU(_ecore_thread_win32_lock);
|
||||||
|
printf(" * thread create 1: %p\n", t);
|
||||||
|
printf(" * thread create 2: %p\n", t->thread);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define PHC(x, f, d) _ecore_thread_win32_create(&(x), (LPTHREAD_START_ROUTINE)f, d)
|
# define PHC(x, f, d) _ecore_thread_win32_create(&(x), (LPTHREAD_START_ROUTINE)f, d)
|
||||||
|
|
||||||
int
|
static int
|
||||||
_ecore_thread_win32_join(win32_thread *x,
|
_ecore_thread_win32_join(win32_thread *x,
|
||||||
void **res)
|
void **res)
|
||||||
{
|
{
|
||||||
|
printf(" * thread join 1 : %p\n", x);
|
||||||
if (!PHE(x, PHS()))
|
if (!PHE(x, PHS()))
|
||||||
{
|
{
|
||||||
|
printf(" * thread join 2 : %p\n", x->thread);
|
||||||
WaitForSingleObject(x->thread, INFINITE);
|
WaitForSingleObject(x->thread, INFINITE);
|
||||||
CloseHandle(x->thread);
|
CloseHandle(x->thread);
|
||||||
}
|
}
|
||||||
if (res) *res = x->val;
|
if (res) *res = x->val;
|
||||||
|
_ecore_thread_win32_threads = eina_list_remove(_ecore_thread_win32_threads, x);
|
||||||
free(x);
|
free(x);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -597,6 +632,9 @@ _ecore_thread_init(void)
|
||||||
_ecore_thread_count_max = 1;
|
_ecore_thread_count_max = 1;
|
||||||
|
|
||||||
#ifdef EFL_HAVE_THREADS
|
#ifdef EFL_HAVE_THREADS
|
||||||
|
# ifdef EFL_HAVE_WIN32_THREADS
|
||||||
|
LKI(_ecore_thread_win32_lock);
|
||||||
|
# endif
|
||||||
LKI(_ecore_pending_job_threads_mutex);
|
LKI(_ecore_pending_job_threads_mutex);
|
||||||
LRWKI(_ecore_thread_global_hash_lock);
|
LRWKI(_ecore_thread_global_hash_lock);
|
||||||
LKI(_ecore_thread_global_hash_mutex);
|
LKI(_ecore_thread_global_hash_mutex);
|
||||||
|
@ -675,6 +713,9 @@ _ecore_thread_shutdown(void)
|
||||||
LKD(_ecore_thread_global_hash_mutex);
|
LKD(_ecore_thread_global_hash_mutex);
|
||||||
LKD(_ecore_running_job_mutex);
|
LKD(_ecore_running_job_mutex);
|
||||||
CDD(_ecore_thread_global_hash_cond);
|
CDD(_ecore_thread_global_hash_cond);
|
||||||
|
# ifdef EFL_HAVE_WIN32_THREADS
|
||||||
|
LKU(_ecore_thread_win32_lock);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue