File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,10 @@ PollEvent PollEvent_copy(PollEvent* e) {
3535 * Platform-specific Poll implementation
3636 * -------------------------------------------------------------------------- */
3737
38- #if defined(__APPLE__ ) || defined(__FreeBSD__ ) || defined(__OpenBSD__ ) || defined(__NetBSD__ )
38+ #if defined(CARP_FORCE_POLL )
39+ #define CARP_USE_POLL 1
40+ #include <poll.h>
41+ #elif defined(__APPLE__ ) || defined(__FreeBSD__ ) || defined(__OpenBSD__ ) || defined(__NetBSD__ )
3942#define CARP_USE_KQUEUE 1
4043#include <sys/event.h>
4144#elif defined(__linux__ )
@@ -246,6 +249,9 @@ Poll Poll_create_() {
246249 p .capacity = 16 ;
247250 p .count = 0 ;
248251 p .fds = (struct pollfd * )CARP_MALLOC (p .capacity * sizeof (struct pollfd ));
252+ if (!p .fds ) {
253+ p .capacity = 0 ;
254+ }
249255 return p ;
250256}
251257
@@ -320,6 +326,10 @@ Array Poll_wait_(Poll* p, int timeout_ms) {
320326 result .len = ready ;
321327 result .capacity = ready > 0 ? ready : 1 ;
322328 result .data = CARP_MALLOC (result .capacity * sizeof (PollEvent ));
329+ if (!result .data ) {
330+ result .len = 0 ; result .capacity = 0 ;
331+ return result ;
332+ }
323333
324334 int j = 0 ;
325335 for (int i = 0 ; i < p -> count && j < ready ; i ++ ) {
Original file line number Diff line number Diff line change 1+ ; Force the POSIX poll(2) backend regardless of platform, so CI can
2+ ; exercise the fallback path even on Linux (epoll) and macOS (kqueue).
3+ (add-cflag "-DCARP_FORCE_POLL")
4+ (load "poll_test.carp")
You can’t perform that action at this time.
0 commit comments