mirror of https://mirror.osredm.com/root/redis.git
Reduce the call of ERR_clear_error (#13903)
From flame graph, we can find `ERR_clear_error` costs much cpu in tls mode, some calls of `ERR_clear_error` are duplicate, in function `tlsHandleEvent`, we call `ERR_clear_error` but we also call `ERR_clear_error` when reading and writing, so it is not necessary. from benchmark, this commit can bring 2-3% performance improvement.
This commit is contained in:
parent
a3f1d09a7d
commit
57a5f51f26
|
@ -637,10 +637,9 @@ static void tlsHandleEvent(tls_connection *conn, int mask) {
|
|||
conn->c.fd, conn->c.state, mask, conn->c.read_handler != NULL, conn->c.write_handler != NULL,
|
||||
conn->flags);
|
||||
|
||||
ERR_clear_error();
|
||||
|
||||
switch (conn->c.state) {
|
||||
case CONN_STATE_CONNECTING:
|
||||
ERR_clear_error();
|
||||
conn_error = anetGetError(conn->c.fd);
|
||||
if (conn_error) {
|
||||
conn->c.last_errno = conn_error;
|
||||
|
@ -674,6 +673,7 @@ static void tlsHandleEvent(tls_connection *conn, int mask) {
|
|||
conn->c.conn_handler = NULL;
|
||||
break;
|
||||
case CONN_STATE_ACCEPTING:
|
||||
ERR_clear_error();
|
||||
ret = SSL_accept(conn->ssl);
|
||||
if (ret <= 0) {
|
||||
WantIOType want = 0;
|
||||
|
@ -1012,6 +1012,7 @@ static int connTLSBlockingConnect(connection *conn_, const char *addr, int port,
|
|||
* which means the specified timeout will not be enforced accurately. */
|
||||
SSL_set_fd(conn->ssl, conn->c.fd);
|
||||
setBlockingTimeout(conn, timeout);
|
||||
ERR_clear_error();
|
||||
|
||||
if ((ret = SSL_connect(conn->ssl)) <= 0) {
|
||||
conn->c.state = CONN_STATE_ERROR;
|
||||
|
|
Loading…
Reference in New Issue