ssize_t socket_implementatio __read char buf int len if __params ssl_h

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
ssize_t socket_implementation::__read(char *buf, int len)
{
if (!__params.ssl_handle)
{
return ::recv( __params.in_fd, buf, len, MSG_NOSIGNAL );
}
int ret = 0;
int err = SSL_ERROR_NONE;
timeout_t wait = 0;
while (true)
{
err = SSL_ERROR_NONE;
ret = ::SSL_read( __params.ssl_handle->__ssl_descr, buf, len );
if (ret <= 0)
{
err = ::SSL_get_error(__params.ssl_handle->__ssl_descr, ret);
if (ssl_io_operation_need_retry(err))
{
DEBUG_SOCK_IMPL("__read() over ssl will be repeated\n");
__on_wait();
common::wait_for_read_plsp(__params.in_fd, 1);
++wait;
if (UNLIKELY( wait >= __msec_wait_timeout ))
{
throw protocol_exception_t( err, "SSL_read ::Connection closed by timeout. code: %d\n", err);
}
continue;
}
else if (ret == 0)
{
throw protocol_exception_t(err, "SSL read error \"Connection closed by client\" code: %d\n", err);
}
else
{
DEBUG_SOCK_IMPL("__read() over ssl has failed fatal error %d\n", err);
//ASSERT(0);
throw protocol_exception_t(err, "SSL read fatal error: %d\n", err);
}
}
break;
}
return ret;
}