Merge branch 'develop' into 'develop'

Issue on thread import for msvc

Hi folks,
some multi thread issue on import current thread on Win32/Win64 OS.

See merge request !21
This commit is contained in:
Daniel Kochmański 2016-05-13 08:13:40 +00:00
commit bc3bfb5de0
5 changed files with 27 additions and 12 deletions

View file

@ -64,6 +64,12 @@ Until now #$ reader macro accepted simple vectors as an argument, what lead
to bugs if vector didn't match specific requirements like the element type
or the arity. Now we sanitize this.
- thread fix on msvc: on windows importing thread was closing the thread
handler so the thread wakeup wasn't working because the handler is not more valid.
- import thread wasn't set upping a proper environment: on some case
the thread was mistakenly thinking that the thread was already registered.
* 16.1.2 changes since 16.0.0
** API changes

View file

@ -66,7 +66,7 @@ HDIR = $(top_srcdir)\h
HFILES = ..\ecl\config.h ..\ecl\atomic_ops.h $(HDIR)\ecl.h $(HDIR)\ecl-cmp.h\
$(HDIR)\object.h $(HDIR)\cs.h $(HDIR)\stacks.h\
$(HDIR)\external.h $(HDIR)\cons.h $(HDIR)\legacy.h\
$(HDIR)\number.h $(HDIR)\page.h
$(HDIR)\number.h $(HDIR)\page.h \
$(HDIR)\internal.h $(HDIR)\ecl-inl.h $(HDIR)\bytecodes.h \
$(HDIR)\impl\math_dispatch.h

View file

@ -201,7 +201,7 @@ _ecl_dealloc_env(cl_env_ptr env)
ecl_internal_error("Unable to deallocate environment structure.");
#else
# if defined(ECL_USE_GUARD_PAGE)
if (VirtualFree(env, sizeof(*env), MEM_RELEASE))
if (!VirtualFree(env, sizeof(*env), MEM_RELEASE))
ecl_internal_error("Unable to deallocate environment structure.");
# endif
#endif

View file

@ -339,14 +339,16 @@ ecl_import_current_thread(cl_object name, cl_object bindings)
#ifdef ECL_WINDOWS_THREADS
{
HANDLE aux = GetCurrentThread();
DuplicateHandle(GetCurrentProcess(),
aux,
GetCurrentProcess(),
&current,
0,
FALSE,
DUPLICATE_SAME_ACCESS);
CloseHandle(current);
if ( !DuplicateHandle(GetCurrentProcess(),
aux,
GetCurrentProcess(),
&current,
0,
FALSE,
DUPLICATE_SAME_ACCESS) )
{
return 0;
}
}
#else
current = pthread_self();
@ -369,7 +371,7 @@ ecl_import_current_thread(cl_object name, cl_object bindings)
{
cl_object processes = cl_core.processes;
cl_index i, size;
for (i = 0, size = processes->vector.dim; i < size; i++) {
for (i = 0, size = processes->vector.fillp; i < size; i++) {
cl_object p = processes->vector.self.t[i];
if (!Null(p) && p->process.thread == current)
return 0;
@ -407,6 +409,10 @@ void
ecl_release_current_thread(void)
{
cl_env_ptr env = ecl_process_env();
#ifdef ECL_WINDOWS_THREADS
HANDLE to_close = env->own_process->process.thread;
#endif
int cleanup = env->cleanup;
thread_cleanup(env->own_process);
#ifdef GBC_BOEHM
@ -414,6 +420,9 @@ ecl_release_current_thread(void)
GC_unregister_my_thread();
}
#endif
#ifdef ECL_WINDOWS_THREADS
CloseHandle(to_close);
#endif
}
@(defun mp::make-process (&key name ((:initial-bindings initial_bindings) ECL_T))

View file

@ -73,7 +73,7 @@ the environment variable TMPDIR to a different value." template))
#+msvc
(defun delete-msvc-generated-files (output-pathname)
(loop for i in '("implib" "exp" "ilk" "pdb")
(loop for i in '("implib" "exp" "ilk" )
for full = (make-pathname :type i :defaults output-pathname)
for truename = (probe-file full)
when truename