2022-03-18 20:49:28 +01:00
|
|
|
#pragma once
|
2022-03-09 19:24:49 +01:00
|
|
|
#ifndef SERVERWORKER
|
|
|
|
|
#define SERVERWORKER
|
|
|
|
|
|
2022-04-09 00:37:56 +02:00
|
|
|
#include <pthread.h>
|
|
|
|
|
|
2022-03-18 20:49:28 +01:00
|
|
|
#include <apiFile.h>
|
|
|
|
|
#include <fileQueue.h>
|
2022-03-27 00:20:34 +01:00
|
|
|
#include <taglialegna.h>
|
2022-04-08 21:32:52 +02:00
|
|
|
#include <threadpool.h>
|
2022-03-18 20:49:28 +01:00
|
|
|
|
2022-05-07 17:28:41 +02:00
|
|
|
/* structure of the args to pass to the worker thread */
|
2022-03-18 20:49:28 +01:00
|
|
|
typedef struct struct_thread {
|
2022-04-04 22:31:14 +02:00
|
|
|
volatile int *quit;
|
2022-03-27 00:20:34 +01:00
|
|
|
int request_pipe;
|
2022-04-25 20:24:55 +02:00
|
|
|
long connfd;
|
2022-05-07 17:28:41 +02:00
|
|
|
queueT *q; /* pointer to file structure */
|
|
|
|
|
taglia_t *taglia; /* pointer to logfile handler */
|
|
|
|
|
threadpool_t *pool; /* pointer to threadpool */
|
2022-03-18 20:49:28 +01:00
|
|
|
pthread_mutex_t *lock;
|
2022-05-07 17:28:41 +02:00
|
|
|
waiting_t **waiting; /* pointer to clients waiting for a lock */
|
2022-03-18 20:49:28 +01:00
|
|
|
} threadT;
|
|
|
|
|
|
2022-05-07 17:28:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* @brief Function executed by a worker thread to handle a single request from a
|
|
|
|
|
* client
|
|
|
|
|
*
|
|
|
|
|
* @param arg: type that holds all needed resources
|
|
|
|
|
*/
|
2022-03-09 19:24:49 +01:00
|
|
|
void threadF(void *arg);
|
|
|
|
|
|
|
|
|
|
#endif /* SERVERWORKER */
|