added extra checks for socket accept
This commit is contained in:
parent
0a5896b16b
commit
bd52dcf0bc
@ -493,7 +493,7 @@ class ServerSocket(Socket)
|
||||
| cliaddr clisck cliact |
|
||||
cliaddr := SocketAddress new.
|
||||
clisck := self _accept: cliaddr.
|
||||
if (clisck notError)
|
||||
if (clisck notNil)
|
||||
{
|
||||
## the _accept method doesn't invoke the initialize method.
|
||||
## i should invoke it manually here.
|
||||
@ -506,7 +506,6 @@ class ServerSocket(Socket)
|
||||
clisck beWatched.
|
||||
}
|
||||
else { clisck close }.
|
||||
|
||||
}.
|
||||
].
|
||||
}
|
||||
|
@ -218,23 +218,39 @@ static moo_pfrc_t pf_accept_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||
newfd = accept4(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), &addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC);
|
||||
if (newfd == -1)
|
||||
{
|
||||
if (errno != ENOSYS)
|
||||
if (errno == ENOSYS) goto normal_accept;
|
||||
|
||||
if (errno != EWOULDBLOCK && errno != EAGAIN)
|
||||
{
|
||||
moo_seterrwithsyserr (moo, errno);
|
||||
return MOO_PF_FAILURE;
|
||||
}
|
||||
|
||||
/* return nil if accept() is not ready to accept a socket */
|
||||
MOO_STACK_SETRET (moo, nargs, moo->_nil);
|
||||
return MOO_PF_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto accept_done;
|
||||
}
|
||||
normal_accept:
|
||||
#endif
|
||||
|
||||
newfd = accept(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), &addrlen);
|
||||
if (newfd == -1)
|
||||
{
|
||||
if (errno != EWOULDBLOCK && errno != EAGAIN)
|
||||
{
|
||||
moo_seterrwithsyserr (moo, errno);
|
||||
return MOO_PF_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/* return nil if accept() is not ready to accept a socket */
|
||||
MOO_STACK_SETRET (moo, nargs, moo->_nil);
|
||||
return MOO_PF_SUCCESS;
|
||||
}
|
||||
fl = fcntl(newfd, F_GETFL, 0);
|
||||
if (fl == -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user