Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
===== 6.1.2 =====

====== Fixes ======

* fix initialisation of lock on Windows. (Mark Elvers, David Allsopp, #1103, #1107, #1104)

===== 6.1.1 =====

====== Fixes ======
Expand Down
9 changes: 7 additions & 2 deletions src/unix/lwt_unix_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,13 @@ CAMLprim value lwt_unix_start_job(value val_job, value val_async_method) {
lwt_unix_async_method async_method = Int_val(val_async_method);
int done = 0;

/* Ensure threading is initialized before using pool_mutex.
On Windows, CRITICAL_SECTION must be initialized before use;
unlike pthreads, zero-initialized CRITICAL_SECTIONs are invalid. */
if (async_method != LWT_UNIX_ASYNC_METHOD_NONE) {
initialize_threading();
}

/* Fallback to synchronous call if there is no worker available and
we can not launch more threads. */
if (async_method != LWT_UNIX_ASYNC_METHOD_NONE) {
Expand All @@ -1087,8 +1094,6 @@ CAMLprim value lwt_unix_start_job(value val_job, value val_async_method) {

case LWT_UNIX_ASYNC_METHOD_DETACH:
case LWT_UNIX_ASYNC_METHOD_SWITCH:
initialize_threading();

lwt_unix_mutex_init(&job->mutex);

lwt_unix_mutex_lock(&pool_mutex);
Expand Down
Loading