aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2020-01-09 21:04:26 +0100
committerGilles Chehade <gilles@poolp.org>2020-01-09 21:04:26 +0100
commit0bab441c205c85eeb84a0c831556c8066ebde7b8 (patch)
tree5e4907de40603d931f49d175218c357aa13e85fc
parentMerge branch 'libtls' into portable-libtls (diff)
downloadOpenSMTPD-0bab441c205c85eeb84a0c831556c8066ebde7b8.tar.xz
OpenSMTPD-0bab441c205c85eeb84a0c831556c8066ebde7b8.zip
we don't want to link opensmtpd to -lpthread, make tls monothreaded
for now, i'll figure a way to move that to a configure knob
-rw-r--r--openbsd-compat/libtls/tls.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/openbsd-compat/libtls/tls.c b/openbsd-compat/libtls/tls.c
index a7e8fe7d..35362829 100644
--- a/openbsd-compat/libtls/tls.c
+++ b/openbsd-compat/libtls/tls.c
@@ -17,9 +17,13 @@
#include <sys/socket.h>
+#define MONOTHREADED
+
#include <errno.h>
#include <limits.h>
+#ifndef MONOTHREADED
#include <pthread.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -58,11 +62,14 @@ tls_do_init(void)
int
tls_init(void)
{
+#ifndef MONOTHREADED
static pthread_once_t once = PTHREAD_ONCE_INIT;
if (pthread_once(&once, tls_do_init) != 0)
return -1;
-
+#else
+ tls_do_init();
+#endif
return tls_init_rv;
}
@@ -257,9 +264,13 @@ tls_configure(struct tls *ctx, struct tls_config *config)
if (config == NULL)
config = tls_config_default;
+#ifndef MONOTHREADED
pthread_mutex_lock(&config->mutex);
config->refcount++;
pthread_mutex_unlock(&config->mutex);
+#else
+ config->refcount++;
+#endif
tls_config_free(ctx->config);