Skip to content

Commit

Permalink
mxshadowsrv: Reintroduce DEBUG_MAX_CONNECTS
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed May 20, 2021
1 parent 55d9b15 commit a7ecdbb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mxshadowsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ static struct stat statbuf; // protected by shadow_mutex
static SSL_CTX *ssl_ctx;
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 @@ -189,6 +192,10 @@ static void process_client(int socket) {
static void *client_thread(void *arg) {

while (1) {
#ifdef DEBUG_MAX_CONNECTS
if ( __sync_fetch_and_sub(&debug_remaining_connects, 1) <= 0)
return NULL;
#endif
int _cleanup_(free_fd) socket = accept4(listen_socket, NULL, NULL, SOCK_NONBLOCK);
if (socket == -1 ) { perror("accept"); exit(1); }
validate_shadow(&shadow_buf, filename, &statbuf);
Expand Down

0 comments on commit a7ecdbb

Please sign in to comment.