client: count number of threads

This commit is contained in:
Thomas Schoebel-Theuer 2020-01-22 14:19:14 +01:00 committed by Thomas Schoebel-Theuer
parent 5179c28b91
commit 7618064cc4
2 changed files with 7 additions and 0 deletions

View File

@ -530,6 +530,7 @@ int receiver_thread(void *data)
struct client_brick *brick = output->brick;
int status = 0;
atomic_inc(&brick->receiver_count);
while (brick->power.button && !brick_thread_should_stop()) {
struct mars_cmd cmd = {};
struct list_head *tmp;
@ -673,6 +674,7 @@ int receiver_thread(void *data)
}
mars_shutdown_socket(&ch->socket);
atomic_dec(&brick->receiver_count);
return status;
}
@ -793,6 +795,7 @@ static int sender_thread(void *data)
if (atomic_inc_return(&sender_count) == 1)
mars_limit_reset(&client_limiter);
atomic_inc(&brick->sender_count);
while (brick->power.button && !brick_thread_should_stop()) {
struct list_head *tmp = NULL;
@ -940,6 +943,7 @@ static int sender_thread(void *data)
wake_up_interruptible_all(&output->bundle.sender_event);
MARS_DBG("sender terminated\n");
atomic_dec(&brick->sender_count);
return status;
}

View File

@ -54,6 +54,9 @@ struct client_brick {
bool separate_reads;
// readonly from outside
int connection_state; // 0 = switched off, 1 = not connected, 2 = connected
/* internal */
atomic_t sender_count;
atomic_t receiver_count;
};
struct client_input {