MCPcopy Create free account
hub / github.com/apache/thrift / write_partial

Method write_partial

lib/cpp/src/thrift/transport/TSSLSocket.cpp:546–584  ·  view source on GitHub ↗

* Returns number of bytes written in SSL Socket. * If eventSafe is set, and it may returns 0 bytes then write method * needs to be called again until it is successfull or it throws * exception incase of failure. */

Source from the content-addressed store, hash-verified

544 * exception incase of failure.
545*/
546uint32_t TSSLSocket::write_partial(const uint8_t* buf, uint32_t len) {
547 initializeHandshake();
548 if (!checkHandshake())
549 return 0;
550 // loop in case SSL_MODE_ENABLE_PARTIAL_WRITE is set in SSL_CTX.
551 uint32_t written = 0;
552 while (written < len) {
553 ERR_clear_error();
554 int32_t bytes = SSL_write(ssl_, &buf[written], len - written);
555 if (bytes <= 0) {
556 int errno_copy = THRIFT_GET_SOCKET_ERROR;
557 int error = SSL_get_error(ssl_, bytes);
558 switch (error) {
559 case SSL_ERROR_SYSCALL:
560 if ((errno_copy != THRIFT_EINTR)
561 && (errno_copy != THRIFT_EAGAIN)) {
562 break;
563 }
564 // fallthrough
565 case SSL_ERROR_WANT_READ:
566 case SSL_ERROR_WANT_WRITE:
567 if (isLibeventSafe()) {
568 return 0;
569 }
570 else {
571 // in the case of SSL_ERROR_SYSCALL we want to wait for an write event again
572 waitForEvent(error == SSL_ERROR_WANT_READ);
573 continue;
574 }
575 default:;// do nothing
576 }
577 string errors;
578 buildErrors(errors, errno_copy, error);
579 throw TSSLException("SSL_write: " + errors);
580 }
581 written += bytes;
582 }
583 return written;
584}
585
586void TSSLSocket::flush() {
587 resetConsumedMessageSize();

Callers

nothing calls this directly

Calls 2

buildErrorsFunction · 0.85
TSSLExceptionClass · 0.85

Tested by

no test coverage detected