Blob Blame History Raw
From: Razvan Crainea <razvan@opensips.org>
Date: Wed, 13 Sep 2017 17:45:33 +0300
Subject: [PATCH] proto_wss: release lock even if write fails

Detected and fixed by Eric Tamme from OnSIP

(cherry picked from commit 99af2fc44f0b8216bdbe7320d41adb208144ada0)

diff --git a/modules/proto_wss/proto_wss.c b/modules/proto_wss/proto_wss.c
index ec3ed2050..83c91b6bc 100644
--- a/modules/proto_wss/proto_wss.c
+++ b/modules/proto_wss/proto_wss.c
@@ -460,7 +460,6 @@ static int wss_raw_writev(struct tcp_connection *c, int fd,
 		}
 		ret += n;
 	}
-	lock_release(&c->write_lock);
 #else
 	n = 0;
 	for (i = 0; i < iovcnt; i++)
@@ -477,10 +476,9 @@ static int wss_raw_writev(struct tcp_connection *c, int fd,
 	}
 	lock_get(&c->write_lock);
 	n = tls_blocking_write(c, fd, buf, n, &tls_mgm_api);
-	lock_release(&c->write_lock);
-
 #endif /* TLS_DONT_WRITE_FRAGMENTS */
 
 end:
+	lock_release(&c->write_lock);
 	return ret;
 }