server session BUGFIX lock fixes and optimizations
diff --git a/src/session_server_tls.c b/src/session_server_tls.c
index 179f8ea..45a065b 100644
--- a/src/session_server_tls.c
+++ b/src/session_server_tls.c
@@ -719,11 +719,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_cert(cert, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -777,11 +779,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_cert_path(cert_path, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -840,11 +844,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_key(privkey, is_rsa, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -898,11 +904,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_key_path(privkey_path, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -968,11 +976,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_add_trusted_cert(cert, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -1040,11 +1050,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_add_trusted_cert_path(cert_path, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -1128,11 +1140,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_trusted_ca_paths(ca_file, ca_dir, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -1168,11 +1182,13 @@
{
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return;
}
nc_server_tls_clear_certs(endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
}
@@ -1238,11 +1254,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_set_crl_paths(crl_file, crl_dir, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -1278,11 +1296,13 @@
{
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return;
}
nc_server_tls_clear_crls(endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
}
@@ -1340,11 +1360,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_add_ctn(id, fingerprint, map_type, name, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;
@@ -1425,11 +1447,13 @@
int ret;
struct nc_endpt *endpt;
+ /* LOCK */
endpt = nc_server_endpt_lock(endpt_name, NC_TI_OPENSSL);
if (!endpt) {
return -1;
}
ret = nc_server_tls_del_ctn(id, fingerprint, map_type, name, endpt->ti_opts);
+ /* UNLOCK */
nc_server_endpt_unlock(endpt);
return ret;