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

Method peek

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

* Note: This method is not libevent safe. */

Source from the content-addressed store, hash-verified

304 * Note: This method is not libevent safe.
305*/
306bool TSSLSocket::peek() {
307 if (!isOpen()) {
308 return false;
309 }
310 initializeHandshake();
311 if (!checkHandshake())
312 throw TSSLException("SSL_peek: Handshake is not completed");
313 int rc;
314 do {
315 uint8_t byte;
316 rc = SSL_peek(ssl_, &byte, 1);
317 if (rc < 0) {
318 int errno_copy = THRIFT_GET_SOCKET_ERROR;
319 int error = SSL_get_error(ssl_, rc);
320 switch (error) {
321 case SSL_ERROR_SYSCALL:
322 if ((errno_copy != THRIFT_EINTR)
323 && (errno_copy != THRIFT_EAGAIN)) {
324 break;
325 }
326 // fallthrough
327 case SSL_ERROR_WANT_READ:
328 case SSL_ERROR_WANT_WRITE:
329 // in the case of SSL_ERROR_SYSCALL we want to wait for an read event again
330 waitForEvent(error != SSL_ERROR_WANT_WRITE);
331 continue;
332 default:;// do nothing
333 }
334 string errors;
335 buildErrors(errors, errno_copy, error);
336 throw TSSLException("SSL_peek: " + errors);
337 } else if (rc == 0) {
338 ERR_clear_error();
339 break;
340 } else {
341 break;
342 }
343 } while (true);
344 return (rc > 0);
345}
346
347void TSSLSocket::open() {
348 if (isOpen() || server()) {

Callers

nothing calls this directly

Calls 2

TSSLExceptionClass · 0.85
buildErrorsFunction · 0.85

Tested by

no test coverage detected