Skip to content

Commit

Permalink
mxshadowsrc: Remove DEBUG_MAX_CONNECTS
Browse files Browse the repository at this point in the history
Remove debug termination logic, which will be reimplemented in a
different way when we prefork.
  • Loading branch information
donald committed May 20, 2021
1 parent 9129837 commit 89843f1
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions mxshadowsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#include <string.h>
#include <getopt.h>
#include <pthread.h>
#include <semaphore.h>
#ifdef DEBUG_MAX_CONNECTS
#include <sys/wait.h>
#endif

#include "common.h"

Expand Down Expand Up @@ -76,9 +72,6 @@ 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

static void validate_shadow(char **shadow_buf, char *filename, struct stat *statbuf) {
int status = pthread_mutex_lock(&shadow_mutex);
Expand Down Expand Up @@ -271,10 +264,6 @@ int main(int argc, char **argv) {
if (status) { errno = status; perror("sem_init"); exit(1); }

while (1) {
#ifdef DEBUG_MAX_CONNECTS
if (debug_remaining_connects-- == 0)
break;
#endif
int _cleanup_(free_fd) socket = accept4(listen_socket, NULL, NULL, SOCK_NONBLOCK);
if (socket == -1 ) { perror("accept"); exit(1); }
status = sem_wait(&free_worker);
Expand All @@ -289,16 +278,5 @@ int main(int argc, char **argv) {
socket = -1;
status = pthread_detach(thread);
if (status != 0) { errno = status; perror("pthread_detach"); exit(1); }

}
#ifdef DEBUG_MAX_CONNECTS
for (int i=0; i<MAX_THREADS; i++) {
status = sem_wait(&free_worker);
if (status == -1) { perror("sem_wait"); exit(1); }
}
/* Valgrinds checks on exit() race with pthread_exit() and Valgrind might report
* a threads stack as lost memory or a Helgrind detected data race. Give threads
* a little time to exit after they posted the semaphore */
sleep(1);
#endif
}

0 comments on commit 89843f1

Please sign in to comment.