Skip to content

Commit 17eab41

Browse files
authored
Merge pull request #7 from avsm/fix-sysconf-on-macos
clamp max open files to 2^19 to fix recent macOS POSIX divergence
2 parents 7fcb143 + b9e20c1 commit 17eab41

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
ocaml-version: ["5.0.0", "4.14.1", "4.13.1", "4.12.1", "4.11.2", "4.10.2", "4.09.1", "4.08.1"]
12+
ocaml-version: ["5.3.0", "4.14.2"]
1313
operating-system: [macos-latest, ubuntu-latest]
1414

1515
runs-on: ${{ matrix.operating-system }}
1616

1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v5
2020

2121
- name: Use OCaml ${{ matrix.ocaml-version }}
22-
uses: ocaml/setup-ocaml@v2
22+
uses: ocaml/setup-ocaml@v3
2323
with:
2424
ocaml-compiler: ${{ matrix.ocaml-version }}
2525

CHANGES.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v0.4 (2025-09-17)
2+
3+
* Clamp max open files to 2^19, as macOS sometimes returns
4+
2^32-1 (#7 @avsm).
5+
16
## v0.3 (2023-03-10)
27

38
* Round timeouts up, not down in Poll.poll (spotted by @talex5)
@@ -6,9 +11,9 @@
611

712
## v0.2 (2023-02-27)
813

9-
* Narrowed the type of Util.fd_of_unix (@reynir)
10-
* Use older school uerror instead of caml_uerror (@reynir)
11-
* Added c_standard to dune build flags (@reynir)
14+
* Narrowed the type of `Util.fd_of_unix` (@reynir)
15+
* Use older school uerror instead of `caml_uerror` (@reynir)
16+
* Added `c_standard` to dune build flags (@reynir)
1217
* Addded ppoll(2) discoverability and a mini compat layer (@haesbaert)
1318
* Improved tests (@haesbaert)
1419
* Re-added macos support (@haesbaert)

lib/iomux_stubs.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,14 @@ caml_iomux_poll_get_fd(value v_fds, value v_index)
150150
* Util
151151
*/
152152

153-
value /* noalloc */
153+
value
154154
caml_iomux_poll_max_open_files(value v_unit)
155155
{
156-
return (Val_int(sysconf(_SC_OPEN_MAX)));
156+
CAMLparam1(v_unit);
157+
long r = sysconf(_SC_OPEN_MAX);
158+
if (r == -1) /* this allocs */
159+
uerror("poll_max_open_files", Nothing);
160+
else if (r > 524288)
161+
r = 524288;
162+
CAMLreturn (Val_int(r));
157163
}

lib/util.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Raw = struct
2-
external max_open_files : unit -> int = "caml_iomux_poll_max_open_files" [@@noalloc]
2+
external max_open_files : unit -> int = "caml_iomux_poll_max_open_files"
33
end
44

55
let max_open_files = Raw.max_open_files

0 commit comments

Comments
 (0)