Skip to content

Commit

Permalink
mxshadowsrc: Hoist two variables into static context
Browse files Browse the repository at this point in the history
For prefork we need the listen_socket and the filename in the threads,
so hoist these variables up into the static context.
  • Loading branch information
donald committed May 20, 2021
1 parent e84dd2b commit 9129837
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mxshadowsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static char *shadow_buf = NULL; // protected by shadow_mutex
static struct stat statbuf; // protected by shadow_mutex
static SSL_CTX *ssl_ctx;
static sem_t free_worker;
static int listen_socket;
static char *filename;
#ifdef DEBUG_MAX_CONNECTS
static int debug_remaining_connects = DEBUG_MAX_CONNECTS;
#endif
Expand Down Expand Up @@ -239,7 +241,7 @@ int main(int argc, char **argv) {
die_usage(argv[0]);
if (optind+1 != argc)
die_usage(argv[0]);
char *filename = argv[optind++];
filename = argv[optind++];

SSL_CTX *_ssl_ctx _cleanup_(free_ssl_ctx) = SSL_CTX_new(TLS_server_method());
if (_ssl_ctx == NULL) { psslerror("SSL_CTX_new"); return 1; }
Expand All @@ -248,7 +250,7 @@ int main(int argc, char **argv) {
if (SSL_CTX_use_PrivateKey_file(ssl_ctx, key_file, SSL_FILETYPE_PEM) <= 0 ) { psslerror("SSL_CTX_use_PrivateKey_file"); return 1; }
if (SSL_CTX_use_certificate_file(ssl_ctx, cert_file, SSL_FILETYPE_PEM) <= 0) { psslerror("SSL_CTX_use_certificate_file"); return 1; }

int listen_socket = socket(AF_INET, SOCK_STREAM, 0);
listen_socket = socket(AF_INET, SOCK_STREAM, 0);
if (listen_socket == -1) { perror("socket"); return 1; }

static int true = 1;
Expand Down

0 comments on commit 9129837

Please sign in to comment.