Fix CID 1134520

This commit is contained in:
jvoisin 2014-05-09 11:08:49 +02:00
parent 1a6dedb5e8
commit e483309b9b

View File

@ -385,13 +385,18 @@ R_API RSocket *r_socket_accept(RSocket *s) {
}
R_API int r_socket_block_time (RSocket *s, int block, int sec) {
int ret;
if (!s) return R_FALSE;
#if __UNIX__
{
int flags = fcntl (s->fd, F_GETFL, 0);
fcntl (s->fd, F_SETFL, block?
if (flags < 0)
return R_FALSE;
ret = fcntl (s->fd, F_SETFL, block?
(flags & ~O_NONBLOCK):
(flags | O_NONBLOCK));
if (ret < 0)
return R_FALSE;
}
#elif __WINDOWS__
// HACK: nonblocking io on w32 behaves strange