CARS
|
#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_t * | freeUserList () |
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_t * | appendList (reqoff_t *list, reqoff_t *elem) |
int | appendReqOff (message_t *mess, char *depart, char *arrival, int place, int send_fd, char *user) |
reqoff_t * | freeReqOffList (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_t * | freeAssocList (assoc_t *list) |
reqoff_t * | newRemainOffer (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_t * | list = NULL |
graph_t * | map |
reqoff_t * | request = NULL |
reqoff_t * | offer = 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 |
Si dichiara che il contenuto di questo file e' in ogni sua parte opera originale dell' autore.
#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 |
Valore false
Referenced by add_edge(), findRec(), goingBackToSleep(), is_correct_label(), is_correct_labelarray(), is_double(), is_edge(), isEqualCity(), main(), new_graph(), str_pars(), and worker_thread().
#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 |
Valore true
Referenced by add_edge(), findActivateThread(), findAssociation(), findRec(), is_correct_label(), is_correct_labelarray(), is_double(), is_edge(), main(), str_pars(), and worker_thread().
#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().
Tipo utilizzato per gestire gli step di un match
Tipo utilizzato per le credentiali dell'utente
int addNewUser | ( | char * | user, |
char * | pass | ||
) |
Aggiunge un nuovo utente e lo imposta come attivo
[in] | user | stringa contenente il nome utente del nuovo utente |
[in] | pass | stringa contenente la password del nuovo utente |
References credential::active, list, LUSERNAME, mux_user, credential::next, credential::password, and credential::username.
Referenced by worker_thread().
Aggiugne un elemento in fondo ad una coda di offerte/richieste
[in] | list | coda in cui inserire |
[in] | elem | elemento da inserire |
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
[in] | mess | il messaggio da verificare |
[out] | depart | se il messaggio e' corretto, scrive su depart la citta' indicata come partenza |
[out] | arrival | se il messaggio e' corretto, scrive su depart la citta' indicata come arrivo |
[out] | place | se il messaggio e' corretto, scrive place il numero dei posti dell'offerta (se e' una offerta, altrimenti il valore non e' significativo) |
MESSAGE_CORRECT | se il messaggio e' corretto |
NUMERIC_ERROR | se e' presente un errore nel numero dei posti |
DEPARTURE_NOT_FOUND | se la partenza non e' stata trovata nel grafo |
ARRIVAL_NOT_FOUND | se l'arrivo non e' stato trovato nel grafo |
DEPARTURE_TOO_LENGTH | se la partenza e' troppo lunga |
ARRIVAL_TOO_LENGTH | se l'arrivo e' troppo lungo |
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.
[in] | user | il nome utente di chi ha effettuato la richiesta |
[in] | elem | puntatore allo step del match di cui si desidera la stringa |
NULL | se e' avvenuto un errore |
il | puntatore 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
[in] | sig | numero del segnale |
Referenced by main().
int extractLoginData | ( | message_t * | mess, |
char * | user, | ||
char * | pass, | ||
char * | sck | ||
) |
Estrae i dati di login da un messaggio
[in] | mess | il messaggio di login |
[out] | user | la stringa che conterra' l'utente (gia' allocata) |
[out] | pass | la stringa che conterra' la password (gia' allocata) |
[out] | sck | la stringa che conterra' il nome del socket (gia' allocata) |
0 | se i dati sono estratti correttamente |
-1 | altrimenti |
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
[in] | receive_fd | il file descriptor della socket da assegnare al nuovo worker |
[in] | init | vale 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
[in] | r | la richiesta da elaborare |
Invoca la funzione ricorsiva 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().
Libera la lista del percorso trovato
NULL |
References assoc::next.
Referenced by findAssociation().
Libera una coda delle richieste/offerte
NULL |
References list, reqoff::next, and reqoff::path.
Referenced by match().
credential_t* freeUserList | ( | ) |
Libera la lista degli utenti
NULL |
References list, and credential::next.
Referenced by main().
int getFlagSig | ( | ) |
Ritorna il valore della variabile received_signal
il | valore della variabile suddetta |
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
[in] | my_id | l'indice nel pool di thread del worker |
[out] | user | la stringa contente l'utente, da resettare |
[out] | pass | la stringa contente la password, da resettare |
[out] | sck | la stringa contente il socket, da resettare |
[out] | buff | la stringa contente il buffer del messaggio in ingresso, da resettare |
[out] | sig | vale 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
References received_signal.
Referenced by signal_handler().
void increaseRequests | ( | int | my_id | ) |
Aumenta il numero delle richieste relative al singolo worker
[in] | my_id | l'indice nel pool di thread del worker |
References mux_pool, and worker::sentreqs.
Referenced by worker_thread().
void initializePool | ( | ) |
Inizializza il pool di thread
References worker::active, cond, worker::in_sck, worker::out_sck, POOL_SIZE, and worker::sentreqs.
Referenced by main().
int isCorrectUser | ( | char * | user, |
char * | pass | ||
) |
Controlla la correttezza di un utente
References credential::active, list, mux_user, credential::next, credential::password, USER_ALREADY_ON, USER_CORRECT, USER_INVALID, USER_INVALID_PASS, USER_NOT_FOUND, and credential::username.
Referenced by worker_thread().
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
[in] | user | nome 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
[in] | user | nome 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.
[in] | depart | la stringa contentente la partenza |
[in] | arriv | la stringa contentente l'arrivo |
[in] | user | la stringa contentente l'utente |
[in] | path | la stringa contentente il path |
[in] | type | il tipo (nel caso in cui si debba utilizzare per spaccare una richiesta, nel nostro caso vale sempre MSG_OFFER) |
[in] | share_fd | il file descriptor relativo all'offerta |
NULL | in caso di errore |
il | puntatore 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
[in] | list | la 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
[out] | out | Il messaggio |
[in] | type | il 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
[in] | my_id | l'indice nel pool di thread del worker |
[in] | out_fd | il 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
[out] | out | Il 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
[out] | out | Il messaggio |
[in] | buff | il 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
[out] | out | Il 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
-1 | se non si e' riusciti ad avviare un thread |
0 | negli 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
[in,out] | t | il TID del thread avviato |
[in] | routine | la funzione che indica il thread da avviare |
[in] | arg | il parametro della funzione |
[in] | message | Nome del thread, in modo da poter scrivere a video l'errore |
0 | se il thread e' stato avviato correttamente |
-1 | se 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
[in] | ass | il 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
[in] | my_id | l'indice nel pool di thread del worker |
[out] | receive_fd | conterra' 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
[in] | me | puntatore 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
[in] | assoc | puntatore alla associazione da scrivere |
References log_fd.
Referenced by findAssociation().
list = NULL |
Lista degli utenti attivi
Referenced by addNewUser(), appendList(), findAssociation(), freeReqOffList(), freeUserList(), isCorrectUser(), loginUser(), logoutUser(), and printLists().
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().
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
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
Referenced by addNewUser(), isCorrectUser(), loginUser(), and logoutUser().
int num[POOL_SIZE] |
Vettore utilizzato per passare i parametri agli worker
Referenced by checkValidMessage(), and startWorker().
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