Skip to content

Commit

Permalink
Check for availability of MSG_DONTWAIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 12, 2024
1 parent 94d5dc8 commit 70f1b72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/socket/basicsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,12 @@ bsock_readable_p(VALUE self)
RB_IO_POINTER(self, fptr);

char buffer[1];
#ifdef MSG_DONTWAIT
int result = recv(fptr->fd, buffer, 1, MSG_PEEK | MSG_DONTWAIT);
#else
rb_io_set_nonblock(fptr);
int result = recv(fptr->fd, buffer, 1, MSG_PEEK);
#endif

if (result > 0) {
return Qtrue;
Expand Down

0 comments on commit 70f1b72

Please sign in to comment.