-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkerMask_t.h
33 lines (27 loc) · 902 Bytes
/
workerMask_t.h
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
#ifndef WORKERMASK_H
#define WORKERMASK_H
#include <util.h>
#include <pthread.h>
//Ogni thread che si occupa di un client memorizza in questa struttura:
typedef struct workerMask{
int fd; //FD con un client
pthread_t tid; //ID del thread che se ne occupa
int end; //Flag di chiusura FD
int attivo; //Ancora in uso
} workerMask_t;
#define INIZIALIZZA(m) \
m.fd=-1; \
m.tid=-1; \
m.end=0; \
m.attivo=0;
void inizializza(workerMask_t m[], int size){
int i=0;
for (int i = 0; i < size; i++)
INIZIALIZZA(m[i])
}
int getIndex(workerMask_t m[],int fd){
for (int i = 0; i < MAXCONNECTIONS; i++)
if (m[i].fd == fd) return i;
return -1;
}
#endif //WORKERMASK_H