Skip to content

Commit 19db1dd

Browse files
author
Ole John Aske
committed
Bug#35693207 TLS_BUSY_TRY_AGAIN handling need to update whatever was sent
In case Transporter::doSend() received a TLS_BUSY_TRY_AGAIN status from writev() it returned immediately without updating the 'sum_sent' of buffered data being sent before the failure. This patch will 'break' out of the send-loop instead of just returning. We will then fall through to the code where such status update is supposed to take place. The code for checking TLS_BUSY_TRY_AGAIN is also moved into the code section where we handle errors (nBytesSent <= 0) Change-Id: I1af2ba15626d9219716acc0a0d01eb4766f9eda9
1 parent 4d4be52 commit 19db1dd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

storage/ndb/src/common/transporter/TCP_Transporter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,20 +394,14 @@ TCP_Transporter::doSend(bool need_wakeup)
394394
}
395395
}
396396

397-
if (Uint32(nBytesSent) == remain) //Completed this send
397+
if (likely(Uint32(nBytesSent) == remain)) //Completed this send
398398
{
399399
sum_sent += nBytesSent;
400400
assert(sum >= sum_sent);
401401
remain = sum - sum_sent;
402402
//g_eventLogger->info("Sent %d bytes on trp %u", nBytesSent, getTransporterIndex());
403403
break;
404404
}
405-
else if (nBytesSent == TLS_BUSY_TRY_AGAIN)
406-
{
407-
// TLS is doing protocol layer stuff. We need to keep polling and
408-
// trying to send until it is done.
409-
return true;
410-
}
411405
else if (nBytesSent > 0) //Sent some, more pending
412406
{
413407
sum_sent += nBytesSent;
@@ -434,10 +428,16 @@ TCP_Transporter::doSend(bool need_wakeup)
434428
iov[pos].iov_base = ((char*)(iov[pos].iov_base))+nBytesSent;
435429
}
436430
}
437-
else //Send failed, terminate
431+
else //Send failed, handle or disconnect?
438432
{
439433
const int err = ndb_socket_errno();
440434

435+
if (nBytesSent == TLS_BUSY_TRY_AGAIN)
436+
{
437+
// In case TLS was 'BUSY' TransporterRegistry will send-retry later.
438+
break;
439+
}
440+
441441
#if defined DEBUG_TRANSPORTER
442442
g_eventLogger->error("Send Failure(disconnect==%d) to node = %d "
443443
"nBytesSent = %d "
@@ -559,7 +559,7 @@ TCP_Transporter::doReceive(TransporterReceiveHandle& recvdata)
559559

560560
if(nBytesRead == TLS_BUSY_TRY_AGAIN) return TLS_BUSY_TRY_AGAIN;
561561

562-
if (nBytesRead > 0)
562+
if (likely(nBytesRead > 0))
563563
{
564564
receiveBuffer.sizeOfData += nBytesRead;
565565
receiveBuffer.insertPtr += nBytesRead;

storage/ndb/src/common/util/NdbSocket.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ static ssize_t handle_ssl_error(int err, const char * fn) {
189189
return 0; // caller should close the socket
190190
case SSL_ERROR_WANT_READ:
191191
case SSL_ERROR_WANT_WRITE:
192-
return TLS_BUSY_TRY_AGAIN;
192+
// FIXME Bug#3569340:
193+
//
194+
// Note that for upper transporter layers we expect either 0 or -1
195+
// to be returned in case of failures.
196+
return TLS_BUSY_TRY_AGAIN; // <- return -1;
193197
case SSL_ERROR_SYSCALL:
194198
return -1; // caller should check errno and close the socket
195199
case SSL_ERROR_ZERO_RETURN:

0 commit comments

Comments
 (0)