Skip to content

Commit

Permalink
remove the scoped nonblocking set code
Browse files Browse the repository at this point in the history
  • Loading branch information
jakesmith committed Jul 19, 2024
1 parent bd9d8d3 commit 763ddb6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
18 changes: 0 additions & 18 deletions system/jlib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,6 @@ void CSocket::readtms(void* buf, size32_t min_size, size32_t max_size, size32_t
/*
* Read at least min_size bytes, up to max_size bytes.
* Reads as much as possible off socket until block detected.
* Uses non-blocking (in theory could avoid if infinite timeout and min_size==max_size, but not worth the complexity).
* NB: If min_size==0 then will return asap if no data is avail.
* NB: If min_size==0, but notified of graceful close, throw graceful close exception.
* NB: timeout is meaningless if min_size is 0
Expand All @@ -1986,7 +1985,6 @@ void CSocket::readtms(void* buf, size32_t min_size, size32_t max_size, size32_t
if (state != ss_open)
THROWJSOCKEXCEPTION(JSOCKERR_not_opened);

ScopedNonBlockingMode scopedNonBlockingMode(this);
CCycleTimer timer;
while (true)
{
Expand Down Expand Up @@ -2137,7 +2135,6 @@ size32_t CSocket::writetms(void const* buf, size32_t minSize, size32_t size, uns
if (state != ss_open)
THROWJSOCKTARGETEXCEPTION(JSOCKERR_not_opened);

ScopedNonBlockingMode scopedNonBlockingMode(this);
while (true)
{
unsigned retrycount=100;
Expand Down Expand Up @@ -7295,18 +7292,3 @@ extern jlib_decl void shutdownAndCloseNoThrow(ISocket * optSocket)
e->Release();
}
}

////
void ScopedNonBlockingMode::init(ISocket *_socket)
{
socket = _socket;
if (socket->set_nonblock(true)) // was already nonblocking
socket = nullptr; // nothing to reset in dtor
}

ScopedNonBlockingMode::~ScopedNonBlockingMode()
{
// only applicable if resetting back to nonblocking = false
if (socket)
socket->set_nonblock(false);
}
8 changes: 0 additions & 8 deletions system/jlib/jsocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,6 @@ class jlib_decl CSingletonSocketConnection: implements IConversation, public CIn

extern jlib_decl void shutdownAndCloseNoThrow(ISocket * optSocket); // Safely shutdown and close a socket without throwing an exception.

struct jlib_decl ScopedNonBlockingMode
{
ISocket *socket = nullptr;
void init(ISocket *_socket);
ScopedNonBlockingMode(ISocket *_socket) { init(_socket); }
~ScopedNonBlockingMode();
};


#ifdef _WIN32
#define SOCKETERRNO() WSAGetLastError()
Expand Down
2 changes: 0 additions & 2 deletions system/security/securesocket/securesocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ void CSecureSocket::readtms(void* buf, size32_t min_size, size32_t max_size, siz
// because we may not get another poll notification because SSL internally has read everything.
sizeRead = 0;
CCycleTimer timer;
ScopedNonBlockingMode scopedNonBlockingMode(this);
while (true)
{
ERR_clear_error();
Expand Down Expand Up @@ -960,7 +959,6 @@ size32_t CSecureSocket::writetms(void const* buf, size32_t minSize, size32_t siz
return 0;

CCycleTimer timer;
ScopedNonBlockingMode scopedNonBlockingMode(this);
while (true)
{
int rc = SSL_write(m_ssl, buf, size);
Expand Down

0 comments on commit 763ddb6

Please sign in to comment.