Skip to content

Commit

Permalink
minor review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Jul 12, 2024
1 parent dd72b2e commit fe4d4f0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions system/jlib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ static win_socket_library ws32_lib;
#define JSE_NOTSOCK WSAENOTSOCK
#define JSE_TIMEDOUT WSAETIMEDOUT
#define JSE_CONNREFUSED WSAECONNREFUSED
#define JSE_EAGAIN WSAEWOULDBLOCK
#define JSE_BADF WSAEBADF

#define JSE_INTR WSAEINTR
Expand Down Expand Up @@ -785,6 +786,7 @@ int inet_aton (const char *name, struct in_addr *addr)
#define JSE_NOTSOCK ENOTSOCK
#define JSE_TIMEDOUT ETIMEDOUT
#define JSE_CONNREFUSED ECONNREFUSED
#define JSE_EAGAIN EAGAIN
#define JSE_BADF EBADF


Expand Down Expand Up @@ -1982,7 +1984,7 @@ void CSocket::readtms(void* buf, size32_t min_size, size32_t max_size, size32_t
}
else
{
if (err == JSE_WOULDBLOCK || err == EAGAIN) // if EGAIN or EWOULDBLOCK - no more data to read
if (err == JSE_WOULDBLOCK || err == JSE_EAGAIN) // if EAGAIN or EWOULDBLOCK - no more data to read
{
//NB: in UDP can only reach here if have not read anything so far.

Expand Down Expand Up @@ -2138,7 +2140,7 @@ size32_t CSocket::writetms(void const* buf, size32_t minSize, size32_t size, uns
errclose();
err = JSOCKERR_broken_pipe;
}
if (err == JSE_WOULDBLOCK)
if (err == JSE_WOULDBLOCK || err == JSE_EAGAIN)
{
if (sizeWritten >= minSize)
break;
Expand Down Expand Up @@ -7242,6 +7244,12 @@ extern jlib_decl void shutdownAndCloseNoThrow(ISocket * optSocket)
////
void ScopedNonBlockingMode::init(ISocket *_socket)
{
// NB: for the time being, don't switch to non-blocking mode for UDP connections (may want to revisit).
// It probably does make sense, e.g. to allow readtms/writetms to be called with min_size 0 and return if blocked,
// but we don't depend on it at the moment, and to reduce the impact of these semantic changes, leave UDP as blocking for now.
// It would likely be necessary if UDP+SSL were ever in play.
if (socket->connectionless())
return;
socket = _socket;
if (socket->set_nonblock(true)) // was already nonblocking
socket = nullptr; // nothing to reset in dtor
Expand Down

0 comments on commit fe4d4f0

Please sign in to comment.