Skip to content

Commit

Permalink
Fully initialize custom_operations job_ops
Browse files Browse the repository at this point in the history
It was missing an initializer for `.compare_ext` (since 3.12.1), the
default is `custom_compare_ext_default`; and `.fixed_length` (since
4.08.0) for which `NULL` is good.
  • Loading branch information
MisterDA committed Jan 24, 2022
1 parent 0fd7865 commit 1cb9aad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/unix/lwt_libev_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ static long hash_loop(value loop) { return (long)Ev_loop_val(loop); }

static struct custom_operations loop_ops = {
"lwt.libev.loop", custom_finalize_default, compare_loops,
hash_loop, custom_serialize_default, custom_deserialize_default};
hash_loop, custom_serialize_default, custom_deserialize_default,
custom_compare_ext_default,
#if OCAML_VERSION >= 408000
NULL
#endif
};

/* Do nothing.
Expand Down Expand Up @@ -127,7 +132,12 @@ static long hash_watcher(value watcher) { return (long)Ev_io_val(watcher); }

static struct custom_operations watcher_ops = {
"lwt.libev.watcher", custom_finalize_default, compare_watchers,
hash_watcher, custom_serialize_default, custom_deserialize_default};
hash_watcher, custom_serialize_default, custom_deserialize_default,
custom_compare_ext_default,
#if OCAML_VERSION >= 408000
NULL
#endif
};

/* +-----------------------------------------------------------------+
| IO watchers |
Expand Down
8 changes: 7 additions & 1 deletion src/unix/lwt_unix_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/signals.h>
#include <caml/version.h>

#include <assert.h>
#include <errno.h>
Expand Down Expand Up @@ -989,7 +990,12 @@ static void *worker_loop(void *data) {
/* Description of jobs. */
struct custom_operations job_ops = {
"lwt.unix.job", custom_finalize_default, custom_compare_default,
custom_hash_default, custom_serialize_default, custom_deserialize_default};
custom_hash_default, custom_serialize_default, custom_deserialize_default,
custom_compare_ext_default,
#if OCAML_VERSION >= 40800
NULL
#endif
};

/* Get the job structure contained in a custom value. */
#define Job_val(v) *(lwt_unix_job *)Data_custom_val(v)
Expand Down

0 comments on commit 1cb9aad

Please sign in to comment.