Check for availability of MSG_DONTWAIT.

This commit is contained in:
Samuel Williams 2024-04-12 23:22:50 +12:00
parent 2eacd94951
commit 3244bb931b
No known key found for this signature in database
GPG key ID: A0765423A44728FB

View file

@ -745,7 +745,12 @@ bsock_readable_p(VALUE self)
RB_IO_POINTER(self, fptr); RB_IO_POINTER(self, fptr);
char buffer[1]; char buffer[1];
#ifdef MSG_DONTWAIT
int result = recv(fptr->fd, buffer, 1, MSG_PEEK | 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) { if (result > 0) {
return Qtrue; return Qtrue;