summaryrefslogtreecommitdiff
path: root/src/networking.c
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2020-07-28 11:32:47 +0300
committerOran Agra <oran@redislabs.com>2020-09-01 09:27:58 +0300
commit1c05b87e304ea1016c91858bac94990e48a1c72d (patch)
tree12e9e51647fb860a65b0532c04d0fd26c6cd316a /src/networking.c
parent67750ce3b3ec8855ee698c80e3271b9cf27f17a4 (diff)
downloadredis-1c05b87e304ea1016c91858bac94990e48a1c72d.tar.gz
TLS: Propagate and handle SSL_new() failures. (#7576)
The connection API may create an accepted connection object in an error state, and callers are expected to check it before attempting to use it. Co-authored-by: mrpre <mrpre@163.com> (cherry picked from commit 784ceeb90d84bbc49fc2f2e2e6c7b9fae2524bd5)
Diffstat (limited to 'src/networking.c')
-rw-r--r--src/networking.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index e3b62f151..a3c04efa6 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -895,8 +895,18 @@ void clientAcceptHandler(connection *conn) {
#define MAX_ACCEPTS_PER_CALL 1000
static void acceptCommonHandler(connection *conn, int flags, char *ip) {
client *c;
+ char conninfo[100];
UNUSED(ip);
+ if (connGetState(conn) != CONN_STATE_ACCEPTING) {
+ serverLog(LL_VERBOSE,
+ "Accepted client connection in error state: %s (conn: %s)",
+ connGetLastError(conn),
+ connGetInfo(conn, conninfo, sizeof(conninfo)));
+ connClose(conn);
+ return;
+ }
+
/* Limit the number of connections we take at the same time.
*
* Admission control will happen before a client is created and connAccept()
@@ -925,7 +935,6 @@ static void acceptCommonHandler(connection *conn, int flags, char *ip) {
/* Create connection and client */
if ((c = createClient(conn)) == NULL) {
- char conninfo[100];
serverLog(LL_WARNING,
"Error registering fd event for the new client: %s (conn: %s)",
connGetLastError(conn),