mirror of
https://github.com/openappsec/openappsec.git
synced 2025-06-28 16:41:02 +03:00
Change socket readiness testing
This commit is contained in:
parent
e25f517c19
commit
09868e6d7c
@ -1542,11 +1542,15 @@ MessageConnection::setSocket()
|
|||||||
bool
|
bool
|
||||||
MessageConnection::isBioSocketReady() const
|
MessageConnection::isBioSocketReady() const
|
||||||
{
|
{
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000 && !defined(OPENSSL_NO_SOCK)
|
auto fd = BIO_get_fd(bio.get(), nullptr);
|
||||||
return BIO_socket_wait(BIO_get_fd(bio.get(), NULL), 0, time(NULL));
|
|
||||||
#else // OPENSSL_VERSION_NUMBER >= 0x30000000 && !defined(OPENSSL_NO_SOCK)
|
fd_set rfds;
|
||||||
return true;
|
FD_ZERO(&rfds);
|
||||||
#endif // OPENSSL_VERSION_NUMBER >= 0x30000000 && !defined(OPENSSL_NO_SOCK)
|
FD_SET(fd, &rfds);
|
||||||
|
|
||||||
|
struct timeval tv = { 0, 0 };
|
||||||
|
|
||||||
|
return select(fd + 1, nullptr, &rfds, nullptr, &tv) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1564,11 +1568,6 @@ MessageConnection::connect(const string &host, const string &overwrite_port)
|
|||||||
|
|
||||||
while (timer->getMonotonicTime() < end_time) {
|
while (timer->getMonotonicTime() < end_time) {
|
||||||
counter++;
|
counter++;
|
||||||
if (!isBioSocketReady()) {
|
|
||||||
dbgDebug(D_COMMUNICATION) << "Socket is not ready for use.";
|
|
||||||
if (mainloop != nullptr) mainloop->yield(true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (BIO_do_connect(bio.get()) > 0) {
|
if (BIO_do_connect(bio.get()) > 0) {
|
||||||
dbgDebug(D_COMMUNICATION)
|
dbgDebug(D_COMMUNICATION)
|
||||||
<< "Successfully established new BIO connection. "
|
<< "Successfully established new BIO connection. "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user