CARS
Data Structures | Defines | Typedefs | Functions | Variables

/home/nicola/Dropbox/Progetto SOL/CARS_terfram/src/mgcars.c File Reference

#include "settings.h"
#include "commons.h"
#include "match.h"
#include "comsock.h"
#include "dgraph.h"
#include "shortestpath.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>

Data Structures

struct  credential
struct  worker
struct  reqoff
struct  assoc

Defines

#define TRUE   1
#define FALSE   0
#define INCORRECT_MESSAGE   -1
#define HELP_MESSAGE   0
#define EXIT_MESSAGE   1
#define REQ_MESSAGE   2
#define OFF_MESSAGE   3
#define USER_INVALID   10
#define USER_NOT_FOUND   11
#define USER_INVALID_PASS   12
#define USER_ALREADY_ON   13
#define USER_CORRECT   14
#define MESSAGE_CORRECT   30
#define NUMERIC_ERROR   31
#define DEPARTURE_NOT_FOUND   32
#define ARRIVAL_NOT_FOUND   33
#define DEPARTURE_TOO_LENGTH   34
#define ARRIVAL_TOO_LENGTH   35

Typedefs

typedef struct credential credential_t
typedef struct worker worker_t
typedef struct reqoff reqoff_t
typedef struct assoc assoc_t

Functions

void increaseFlagSig ()
int getFlagSig ()
int checkValidMessage (message_t *mess, char *depart, char *arrival, int *place)
int isCorrectUser (char *user, char *pass)
int extractLoginData (message_t *mess, char *user, char *pass, char *sck)
credential_tfreeUserList ()
int addNewUser (char *user, char *pass)
void loginUser (char *user)
void logoutUser (char *user)
int findActivateThread (int receive_fd, int init)
void initializePool ()
void setShareMessage (message_t *out, char *buff)
void setSharEndMessage (message_t *out)
void setOkMessage (message_t *out)
void setErrorMessage (int type, message_t *out)
reqoff_tappendList (reqoff_t *list, reqoff_t *elem)
int appendReqOff (message_t *mess, char *depart, char *arrival, int place, int send_fd, char *user)
reqoff_tfreeReqOffList (reqoff_t *list)
void printLists (reqoff_t *list)
char * createAssoc (char *user, assoc_t *elem)
int findRec (char *path, assoc_t **l)
void writeToLog (char *assoc)
assoc_tfreeAssocList (assoc_t *list)
reqoff_tnewRemainOffer (char *depart, char *arriv, char *user, char *path, int type, int share_fd)
void updateOfferList (assoc_t *ass)
void findAssociation (reqoff_t *r)
void unlockAll ()
void lockAll ()
void * match ()
void * signal_handler ()
void increaseRequests (int my_id)
void setMyOutSck (int my_id, int out_fd)
void goingBackToSleep (int my_id, char *user, char *pass, char *sck, char *buff, int sig)
void waitForActivation (int my_id, int *receive_fd)
void * worker_thread (void *me)
int tryStartThread (pthread_t *t, void *(*routine)(void *), void *arg, char *message)
int startWorker ()
void dummy ()
static void err_handler (int sig)
void printEnv ()
int main (int argc, char *argv[])

Variables

pthread_mutex_t mux_user = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t mux_pool = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t mux_request = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t mux_offer = PTHREAD_MUTEX_INITIALIZER
worker_t pool [POOL_SIZE]
credential_tlist = NULL
graph_tmap
reqoff_trequest = NULL
reqoff_toffer = NULL
pthread_t matcher
pthread_t handler
pthread_t listener
int num [POOL_SIZE]
int log_fd = -1
volatile sig_atomic_t received_signal = 0

Detailed Description

Author:
Nicola Corti

Si dichiara che il contenuto di questo file e' in ogni sua parte opera originale dell' autore.


Define Documentation

#define ARRIVAL_NOT_FOUND   33

L'arrivo non e' stato trovato

Referenced by checkValidMessage(), and setErrorMessage().

#define ARRIVAL_TOO_LENGTH   35

L'arrivo e' troppo lungo

Referenced by checkValidMessage(), and setErrorMessage().

#define DEPARTURE_NOT_FOUND   32

La partenza non e' stata trovata

Referenced by checkValidMessage(), and setErrorMessage().

#define DEPARTURE_TOO_LENGTH   34

La partenza e' troppo lunga

Referenced by checkValidMessage(), and setErrorMessage().

#define EXIT_MESSAGE   1

Il messaggio e' un messaggio di uscita

#define FALSE   0
#define HELP_MESSAGE   0

Il messaggio e' un messaggio di aiuto

#define INCORRECT_MESSAGE   -1

Il messaggio parsato e' incorretto

#define MESSAGE_CORRECT   30

Il messaggio e' corretto

Referenced by checkValidMessage(), and worker_thread().

#define NUMERIC_ERROR   31

Il numero dei posti contiene un errore

Referenced by checkValidMessage(), and setErrorMessage().

#define OFF_MESSAGE   3

Il messaggio e' un messaggio di offerta

#define REQ_MESSAGE   2

Il messaggio e' un messaggio di richiesta

#define TRUE   1
#define USER_ALREADY_ON   13

L'utente e' gia' loggato da un'altra parte

Referenced by isCorrectUser(), and setErrorMessage().

#define USER_CORRECT   14

L'utente e' corretto

Referenced by isCorrectUser(), and worker_thread().

#define USER_INVALID   10

L'utente non e' valido

Referenced by isCorrectUser(), and setErrorMessage().

#define USER_INVALID_PASS   12

La password non e' corretta

Referenced by isCorrectUser(), and setErrorMessage().

#define USER_NOT_FOUND   11

L'utente non e' stato trovato fra quelli noti

Referenced by isCorrectUser(), and worker_thread().


Typedef Documentation

Tipo utilizzato per gestire gli step di un match

See also:
credential

Tipo utilizzato per le credentiali dell'utente

See also:
credential

Tipo utilizzato per le richieste/offerte

See also:
reqoff

Tipo utilizzato per il pool di thread

See also:
worker

Function Documentation

int addNewUser ( char *  user,
char *  pass 
)

Aggiunge un nuovo utente e lo imposta come attivo

Parameters:
[in]userstringa contenente il nome utente del nuovo utente
[in]passstringa contenente la password del nuovo utente

References credential::active, list, LUSERNAME, mux_user, credential::next, credential::password, and credential::username.

Referenced by worker_thread().

reqoff_t* appendList ( reqoff_t list,
reqoff_t elem 
)

Aggiugne un elemento in fondo ad una coda di offerte/richieste

Parameters:
[in]listcoda in cui inserire
[in]elemelemento da inserire
Attention:
accertarsi di aver acquisito la mutua esclusione prima di invocare questa funzione

References list, and reqoff::next.

Referenced by appendReqOff().

int appendReqOff ( message_t mess,
char *  depart,
char *  arrival,
int  place,
int  send_fd,
char *  user 
)

Crea un nuovo elemento di tipo reqoff_t e lo inserisce nella coda corretta

References appendList(), reqoff::arriv, reqoff::depart, dijkstra(), is_node(), MSG_OFFER, MSG_REQUEST, mux_offer, mux_request, reqoff::next, reqoff::path, reqoff::place, reqoff::share_fd, shpath_to_string(), reqoff::type, and reqoff::user.

Referenced by worker_thread().

int checkValidMessage ( message_t mess,
char *  depart,
char *  arrival,
int *  place 
)

Controlla la validita' del messaggio mess

Parameters:
[in]messil messaggio da verificare
[out]departse il messaggio e' corretto, scrive su depart la citta' indicata come partenza
[out]arrivalse il messaggio e' corretto, scrive su depart la citta' indicata come arrivo
[out]placese il messaggio e' corretto, scrive place il numero dei posti dell'offerta (se e' una offerta, altrimenti il valore non e' significativo)
Return values:
MESSAGE_CORRECTse il messaggio e' corretto
NUMERIC_ERRORse e' presente un errore nel numero dei posti
DEPARTURE_NOT_FOUNDse la partenza non e' stata trovata nel grafo
ARRIVAL_NOT_FOUNDse l'arrivo non e' stato trovato nel grafo
DEPARTURE_TOO_LENGTHse la partenza e' troppo lunga
ARRIVAL_TOO_LENGTHse l'arrivo e' troppo lungo
Attention:
depart e arrival devono essere gia' allocate

References ARRIVAL_NOT_FOUND, ARRIVAL_TOO_LENGTH, message_t::buffer, DEPARTURE_NOT_FOUND, DEPARTURE_TOO_LENGTH, is_node(), LLABEL, MESSAGE_CORRECT, MSG_OFFER, num, and NUMERIC_ERROR.

Referenced by worker_thread().

char* createAssoc ( char *  user,
assoc_t elem 
)

Alloca e restituisce una stringa contenente l'associazione da scrivere sul log e da inviare con un messaggio share.

Parameters:
[in]useril nome utente di chi ha effettuato la richiesta
[in]elempuntatore allo step del match di cui si desidera la stringa
Return values:
NULLse e' avvenuto un errore
ilpuntatore alla stringa altrimenti

References assoc::begin_from, assoc::city_found, cityString(), assoc::found_off, reqoff::path, pathLen(), and reqoff::user.

Referenced by findAssociation().

void dummy ( )

Gestore vuoto per inibire la gestione di default di SIGUSR1

static void err_handler ( int  sig) [static]

Gestore dei segnali di sistema (SIGSEGV, etc...) Visualizza un messaggio di errore e termina immediatamente il processo

Parameters:
[in]signumero del segnale

Referenced by main().

int extractLoginData ( message_t mess,
char *  user,
char *  pass,
char *  sck 
)

Estrae i dati di login da un messaggio

Parameters:
[in]messil messaggio di login
[out]userla stringa che conterra' l'utente (gia' allocata)
[out]passla stringa che conterra' la password (gia' allocata)
[out]sckla stringa che conterra' il nome del socket (gia' allocata)
Return values:
0se i dati sono estratti correttamente
-1altrimenti

References message_t::buffer, message_t::length, and MSG_CONNECT.

Referenced by worker_thread().

int findActivateThread ( int  receive_fd,
int  init 
)

Cerca ed attiva un thread dormiente fra quelli del pool

Parameters:
[in]receive_fdil file descriptor della socket da assegnare al nuovo worker
[in]initvale TRUE se si sta inizializzando lo scheduler, FALSE altrimenti

References worker::active, cond, worker::in_sck, mux_pool, POOL_SIZE, worker::sentreqs, and TRUE.

Referenced by main().

void findAssociation ( reqoff_t r)

Data una richiesta r cerca di crearne un possibile match, e stampa ogni passo del match sul log Inoltre invia un messaggio di share al file descriptor indicato

Parameters:
[in]rla richiesta da elaborare

Invoca la funzione ricorsiva findRec

See also:
findRec

References BUFF_SIZE, message_t::buffer, buffer, createAssoc(), findRec(), freeAssocList(), list, out_message, reqoff::path, sendMessage(), setShareMessage(), reqoff::share_fd, sys_print_1, TRUE, updateOfferList(), reqoff::user, and writeToLog().

Referenced by match().

int findRec ( char *  path,
assoc_t **  l 
)

Cerca di creare un percorso che soddisfi il path, e restituisce il percorso effettuato tramite l

References assoc::begin_from, assoc::city_found, cityMatch(), countCity(), FALSE, assoc::found_off, assoc::next, reqoff::next, nextPath(), offer, reqoff::path, reqoff::place, and TRUE.

Referenced by findAssociation().

assoc_t* freeAssocList ( assoc_t list)

Libera la lista del percorso trovato

Return values:
NULL

References assoc::next.

Referenced by findAssociation().

reqoff_t* freeReqOffList ( reqoff_t list)

Libera una coda delle richieste/offerte

Attention:
da invocare soltanto in fase di chiusura del server
non vengono trattati i problemi di mutua esclusione
Return values:
NULL

References list, reqoff::next, and reqoff::path.

Referenced by match().

credential_t* freeUserList ( )

Libera la lista degli utenti

Attention:
da invocare soltanto in fase di chiusura del server
non vengono trattati i problemi di mutua esclusione
Return values:
NULL

References list, and credential::next.

Referenced by main().

int getFlagSig ( )

Ritorna il valore della variabile received_signal

Return values:
ilvalore della variabile suddetta
See also:
received_signal

References received_signal.

Referenced by main(), match(), and worker_thread().

void goingBackToSleep ( int  my_id,
char *  user,
char *  pass,
char *  sck,
char *  buff,
int  sig 
)

Riporta un worker in fase di attesa

Parameters:
[in]my_idl'indice nel pool di thread del worker
[out]userla stringa contente l'utente, da resettare
[out]passla stringa contente la password, da resettare
[out]sckla stringa contente il socket, da resettare
[out]buffla stringa contente il buffer del messaggio in ingresso, da resettare
[out]sigvale TRUE se si ci sta disattivando in seguito ad un segnale (in tal caso non chiudiamo il socket in uscita), FALSE negli altri casi

References worker::active, BUFF_SIZE, closeSocket(), FALSE, worker::in_sck, LUSERNAME, MAX_PID_CHAR, mux_pool, worker::out_sck, print_1, and worker::sentreqs.

Referenced by worker_thread().

void increaseFlagSig ( )

Incrementa il valore della variabile received_signal

See also:
received_signal

References received_signal.

Referenced by signal_handler().

void increaseRequests ( int  my_id)

Aumenta il numero delle richieste relative al singolo worker

Parameters:
[in]my_idl'indice nel pool di thread del worker

References mux_pool, and worker::sentreqs.

Referenced by worker_thread().

void initializePool ( )

Inizializza il pool di thread

Attention:
da utilizzare solo all'avvia del sistema
non tiene di conto dei problemi di mutua esclusione

References worker::active, cond, worker::in_sck, worker::out_sck, POOL_SIZE, and worker::sentreqs.

Referenced by main().

int isCorrectUser ( char *  user,
char *  pass 
)
void lockAll ( )

Acquisisce la mutua esclusione sul pool di thread, sulla coda richieste e sulla coda offerte

References mux_offer, mux_pool, and mux_request.

Referenced by match().

void loginUser ( char *  user)

Logga un utente nel sistema

Parameters:
[in]usernome utente dell'utente da loggare

References credential::active, list, mux_user, credential::next, and credential::username.

Referenced by worker_thread().

void logoutUser ( char *  user)

Slogga un utente nel sistema

Parameters:
[in]usernome utente dell'utente da sloggare

References credential::active, list, mux_user, credential::next, and credential::username.

Referenced by worker_thread().

int main ( int  argc,
char *  argv[] 
)

Funzione relativa al thread main (listener)

Il main, dopo aver correttamente inizializzato il server, avvia i vari thread del server, e si mette in attesa di connessioni in entrata

Per maggiori dettagli sul thread main leggere la relazione

References acceptConnection(), closeSocket(), createServerChannel(), dummy(), ec_neg1, ec_null, ec_null_c, ec_zero, err_handler(), err_print, FALSE, findActivateThread(), free_graph(), freeUserList(), getFlagSig(), handler, initializePool(), listener, load_graph(), log_fd, LOG_FILE_NAME, match(), matcher, PERM_FILE, POOL_SIZE, print, print_1, print_graph(), printEnv(), signal_handler(), SOCKET_PATH, startWorker(), sys_print, sys_print_1, TRUE, and tryStartThread().

void* match ( )

Funzione relativa al thread match

Il thread match resta in attesa di un messaggio SIGUSR1 oppure dello scadere del quanto di tempo

Successivamente acquisisce la mutua esclusione, elabora tutte le richieste in coda, ed invia i messaggi di share_end

Ad ogni esecuzione svuota la coda delle richieste

Se la macro FREE_OFFER_LIST e' settata, viene liberata la coda delle offerte, altrimenti viene lasciata per le prossime esecuzioni

Successivamente si rimette in attesa.

References BUFF_SIZE, message_t::buffer, buffer, ec_neg1_c, ec_zero_c, findAssociation(), freeReqOffList(), getFlagSig(), lockAll(), reqoff::next, NSEC_TIMER, out_message, POOL_SIZE, print, print_1, printLists(), request, SEC_TIMER, sendMessage(), worker::sentreqs, setSharEndMessage(), sys_print, and unlockAll().

Referenced by main().

reqoff_t* newRemainOffer ( char *  depart,
char *  arriv,
char *  user,
char *  path,
int  type,
int  share_fd 
)

Alloca e restituisce una nuova offerta da un posto, in modo da poter aggiorare la lista delle offerte.

Parameters:
[in]departla stringa contentente la partenza
[in]arrivla stringa contentente l'arrivo
[in]userla stringa contentente l'utente
[in]pathla stringa contentente il path
[in]typeil tipo (nel caso in cui si debba utilizzare per spaccare una richiesta, nel nostro caso vale sempre MSG_OFFER)
[in]share_fdil file descriptor relativo all'offerta
Return values:
NULLin caso di errore
ilpuntatore ad una nuova struttura altrimenti

References reqoff::arriv, reqoff::depart, reqoff::path, reqoff::place, reqoff::share_fd, reqoff::type, and reqoff::user.

Referenced by updateOfferList().

void printEnv ( )

Stampa l'ambiente d'esecuzione del server

References DELAY, LOG_FILE_NAME, MAX_TRY, NSEC_TIMER, NTRIALCONN, POOL_SIZE, print, print_1, SEC_TIMER, and SOCKET_PATH.

Referenced by main().

void printLists ( reqoff_t list)

Stampa una coda di richieste/offerte

Parameters:
[in]listla coda da stampare

References reqoff::arriv, reqoff::depart, list, reqoff::next, reqoff::path, reqoff::place, reqoff::type, and reqoff::user.

Referenced by match().

void setErrorMessage ( int  type,
message_t out 
)

Imposta un messaggio di tipo message_t in modo che sia un messaggio di error valido

Parameters:
[out]outIl messaggio
[in]typeil tipo utilizzato per settare il messaggio di errore

References ARRIVAL_NOT_FOUND, ARRIVAL_TOO_LENGTH, message_t::buffer, DEPARTURE_NOT_FOUND, DEPARTURE_TOO_LENGTH, message_t::length, LLABEL, MSG_NO, NUMERIC_ERROR, USER_ALREADY_ON, USER_INVALID, and USER_INVALID_PASS.

Referenced by worker_thread().

void setMyOutSck ( int  my_id,
int  out_fd 
)

Imposta il valore del socket in uscita del worker

Parameters:
[in]my_idl'indice nel pool di thread del worker
[in]out_fdil file descriptor del socket in uscita

References mux_pool, and worker::out_sck.

Referenced by worker_thread().

void setOkMessage ( message_t out)

Imposta un messaggio di tipo message_t in modo che sia un messaggio di ok valido

Parameters:
[out]outIl messaggio

References message_t::length, and MSG_OK.

Referenced by worker_thread().

void setShareMessage ( message_t out,
char *  buff 
)

Imposta un messaggio di tipo message_t in modo che sia un messaggio di share valido

Parameters:
[out]outIl messaggio
[in]buffil buffer da copiare in quello del messaggio

Il buffer del messaggio deve essere stato gia' allocato

References message_t::buffer, message_t::length, and MSG_SHARE.

Referenced by findAssociation().

void setSharEndMessage ( message_t out)

Imposta un messaggio di tipo message_t in modo che sia un messaggio di share_end valido

Parameters:
[out]outIl messaggio

References message_t::length, and MSG_SHAREND.

Referenced by match().

void* signal_handler ( )

Funzione relativa al thread gestore dei segnali.

Il thread una volta avviato si mette in attesa di segnali SIGINT o SIGTERM. Una volta arrivati tali messaggi coordina la terminazione del server.

Per maggiori informazioni sulla terminazione del server controllare la relazione

References worker::active, closeSocket(), cond, ec_neg1_c, ec_zero_c, increaseFlagSig(), listener, matcher, mux_pool, POOL_SIZE, print, sys_print, and sys_print_1.

Referenced by main().

int startWorker ( )

Avvia tutti gli worker del pool di thread

Return values:
-1se non si e' riusciti ad avviare un thread
0negli altri casi

References mux_pool, num, POOL_SIZE, tryStartThread(), and worker_thread().

Referenced by main().

int tryStartThread ( pthread_t *  t,
void *(*)(void *)  routine,
void *  arg,
char *  message 
)

Prova ad avviare un thread. Nel caso in cui non vi siano sufficienti risorse attende per DELAY secondi e prova di nuovo ad avviarlo per MAX_TRY volte

Parameters:
[in,out]til TID del thread avviato
[in]routinela funzione che indica il thread da avviare
[in]argil parametro della funzione
[in]messageNome del thread, in modo da poter scrivere a video l'errore
Return values:
0se il thread e' stato avviato correttamente
-1se non si e' riusciti ad avviare il thread

References DELAY, err_print_1, and MAX_TRY.

void unlockAll ( )

Rilascia la mutua esclusione sul pool di thread, sulla coda richieste e sulla coda offerte

References mux_offer, mux_pool, and mux_request.

Referenced by match().

void updateOfferList ( assoc_t ass)

Partendo da un passo di un match aggiorna la lista delle offerte

Parameters:
[in]assil passo del match di cui si desidera aggiornare l'offerta.

Se la macro UPDATE_OFFER non e' settata si provvede solamente a diminuire il numero dei posti altrimenti si spacca l'offerta in 2/3

References reqoff::arriv, assoc::begin_from, assoc::city_found, countCity(), cutPath(), reqoff::depart, assoc::found_off, LLABEL, newRemainOffer(), reqoff::next, nextPath(), reqoff::path, reqoff::place, reqoff::share_fd, sys_print_1, reqoff::type, and reqoff::user.

Referenced by findAssociation().

void waitForActivation ( int  my_id,
int *  receive_fd 
)

Si sospende in attesa di essere attivato

Parameters:
[in]my_idl'indice nel pool di thread del worker
[out]receive_fdconterra' il valore del socket in entrata assegnato al worker

References cond, worker::in_sck, and mux_pool.

Referenced by worker_thread().

void* worker_thread ( void *  me)

Funzione relativa al worker

Il worker si mette in attesa di essere risvegliato Appena risvegliato cerca di autenticare l'utente che si sta collegando Una volta verifica la correttezza dell'utente avvia una sessione di messaggi con il client Appena e' terminata tale sessione il thread torna in fase di attesa

Per maggiori informazioni leggere la relazione

Parameters:
[in]mepuntatore all'intero che contiene il numero progressivo nel pool di thread

References addNewUser(), appendReqOff(), BUFF_SIZE, message_t::buffer, checkValidMessage(), ec_neg1_c, ec_zero_c, err_print_1, extractLoginData(), FALSE, getFlagSig(), goingBackToSleep(), in_message, increaseRequests(), isCorrectUser(), message_t::length, LLABEL, loginUser(), logoutUser(), LUSERNAME, MAX_PID_CHAR, MESSAGE_CORRECT, MSG_EXIT, MSG_REQUEST, openConnection(), out_message, print_1, print_2, receiveMessage(), sendMessage(), setErrorMessage(), setMyOutSck(), setOkMessage(), sys_print_1, TRUE, USER_CORRECT, USER_NOT_FOUND, and waitForActivation().

Referenced by startWorker().

void writeToLog ( char *  assoc)

Scrive un'associazione nel file di log

Parameters:
[in]assocpuntatore alla associazione da scrivere

References log_fd.

Referenced by findAssociation().


Variable Documentation

TID del signal handler utilizzato per l'invio dei messaggi

Referenced by main().

list = NULL

TID del listener (main) utilizzato per l'invio dei messaggi

Referenced by main(), and signal_handler().

log_fd = -1

File descriptor del file di log

Referenced by main(), and writeToLog().

map

Grafo orientato del server

TID del matcher utilizzato per l'invio dei messaggi

Referenced by main(), and signal_handler().

mux_offer = PTHREAD_MUTEX_INITIALIZER

Utilizzata per la mutua esclusione sulla coda delle offerte

Referenced by appendReqOff(), lockAll(), and unlockAll().

mux_pool = PTHREAD_MUTEX_INITIALIZER

Utilizzata per la mutua esclusione sul pool di thread

See also:
pool

Referenced by findActivateThread(), goingBackToSleep(), increaseRequests(), lockAll(), setMyOutSck(), signal_handler(), startWorker(), unlockAll(), and waitForActivation().

mux_request = PTHREAD_MUTEX_INITIALIZER

Utilizzata per la mutua esclusione sulla coda delle richieste

Referenced by appendReqOff(), lockAll(), and unlockAll().

mux_user = PTHREAD_MUTEX_INITIALIZER

Utilizzata per la mutua esclusione sulla lista degli utenti

See also:
list

Referenced by addNewUser(), isCorrectUser(), loginUser(), and logoutUser().

int num[POOL_SIZE]

Vettore utilizzato per passare i parametri agli worker

Referenced by checkValidMessage(), and startWorker().

offer = NULL

Coda delle offer pendenti

See also:
reqoff

Referenced by findRec().

Struttura che contiene tutti i dati degli worker

See also:
POOL_SIZE
worker
volatile sig_atomic_t received_signal = 0

Flag che viene utilizzato per coordinare la chiusura del sistema Di default vale 0 Viene settato a 1, appena il signal handler riceve un segnale di terminazione. Questo indica agli worker che devono essere terminati Viene settato a 2, appena tutti gli worker sono terminati Questo indica al thread match che deve terminare

request = NULL

Coda delle richieste pendenti

See also:
reqoff

Referenced by match().