Skip to content

Commit

Permalink
workaround libuv bug under windows
Browse files Browse the repository at this point in the history
uwt.sync was broken during the last releases.
It was not captured by the test cases, because the
tests link also uwt that pull in the initialization
code ...
  • Loading branch information
fdopen committed Aug 19, 2017
1 parent d501847 commit d6b1c35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/uv_fs_sync.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ type loop_mode =
open Uwt_base
include Fs_types

#if HAVE_WINDOWS <> 0
external init_uwt : unit -> unit = "uwt_init_sync_na" NOALLOC
let () = init_uwt ()
#endif

let wrap x =
if Int_result.is_error x then
Error (Int_result.to_error x)
Expand Down
15 changes: 15 additions & 0 deletions src/uwt_stubs_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,26 @@ static struct custom_operations ops_uwt_handle_nf = {
#pragma GCC diagnostic pop
#endif

#ifdef _WIN32
CAMLprim value
uwt_init_sync_na(value unit)
{
(void) unit;
/* workaround libuv bug. see #1488 */
uv_hrtime();
return Val_unit;
}
#endif

CAMLprim value
uwt_init_na(value unit)
{
unsigned int i,j;

#ifdef _WIN32
uv_hrtime();
#endif

/* they must point to the same location. Otherwise the
polymorphic comparison function won't behave as intended */
ops_uwt_handle.identifier = custom_op_name;
Expand Down
3 changes: 3 additions & 0 deletions src/uwt_stubs_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ UWT_EXTERN1(uwt_default_loop);

/* memory handling (c heap) */
UWT_EXTERN1(uwt_init_na);
#ifdef _WIN32
UWT_EXTERN1(uwt_init_sync_na);
#endif

UWT_LOCAL void
uwt__malloc_uv_buf_t(uv_buf_t *, size_t);
Expand Down

0 comments on commit d6b1c35

Please sign in to comment.