Skip to content

Commit

Permalink
Use ceil for poll timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Feb 22, 2025
1 parent e6c8533 commit be35f2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.9.5 (unreleased)
=====
* Make pipe write unblocking.
* Use ceil for `poll` timeout.

0.9.4 (2024-03-18)
=====
Expand Down
5 changes: 3 additions & 2 deletions src/duppy_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <caml/threads.h>

#include <errno.h>
#include <math.h>

/* On native Windows platforms, many macros are not defined. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
Expand Down Expand Up @@ -65,7 +66,7 @@ CAMLprim value caml_poll(value _read, value _write, value _err, value _timeout)
if (Double_val(_timeout) == -1)
timeout = -1;
else
timeout = Double_val(_timeout) * 1000;
timeout = ceil(Double_val(_timeout) * 1000);

nfds += Wosize_val(_read);
nfds += Wosize_val(_write);
Expand Down Expand Up @@ -97,7 +98,7 @@ CAMLprim value caml_poll(value _read, value _write, value _err, value _timeout)

if (ret == -1) {
free(fds);
uerror("poll",Nothing);
uerror("poll", Nothing);
}

for (n = 0; n < nfds; n++) {
Expand Down

0 comments on commit be35f2e

Please sign in to comment.