summaryrefslogtreecommitdiff
blob: 48b5ac62f2ad009912838e95661c935f57b4e2d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <sys/socket.h>

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>

#include "../parameters/parameters.h"

#include "server.h"

void ZoO_server_handle_joining_threads
(
   struct ZoO_server server [const restrict static 1]
)
{
   ZoO_index i;

   pthread_mutex_lock(&(server->workers.mutex));

   for (i = 0; i < server->workers.threads_capacity; ++i)
   {
      if (server->workers.threads[i].state == ZoO_SERVER_JOINING_THREAD)
      {
         pthread_join(server->workers.threads[i].posix_id, (void **) NULL);

         server->workers.threads[i].state = ZoO_SERVER_NO_THREAD;

         server->workers.currently_running -= 1;
      }
   }

   pthread_mutex_unlock(&(server->workers.mutex));
}