Api for managing files

This commit is contained in:
elvis
2022-03-18 20:49:28 +01:00
parent 6519b16e46
commit c8a685272f
6 changed files with 66 additions and 9 deletions

View File

@ -149,8 +149,8 @@ int main(int argc, char *argv[]) {
volatile int quit = 0;
sig_atomic_t stopNewConnections = 0; // true to stop new connections
sig_atomic_t numberOfConnections = 0;
volatile int stopNewConnections = 0; // true to stop new connections
volatile int numberOfConnections = 0;
while(!quit) {
// copio il set nella variabile temporanea per la select

View File

@ -183,14 +183,13 @@ int parser(int len, char *command, queueT *queue, long fd_c, logT* logFileT, pth
removeFile(token2, queue, fd_c, logFileT, lock, waiting);
goto _parser_end;
}
goto _parser_cleanup; // nessun comando riconosciuto
_parser_end:
free(command);
return 0;
// se arrivo qui non ho riconosciuto il comando
_parser_cleanup:
free(command);
return -1;
_parser_end:
free(command);
return 0;
}

View File

@ -1,6 +1,20 @@
#pragma once
#ifndef SERVERWORKER
#define SERVERWORKER
#include <apiFile.h>
#include <fileQueue.h>
// struttura dati che contiene gli argomenti da passare ai worker threads
typedef struct struct_thread {
long *args;
queueT *q; // puntatore alla queue dei file
// logT *logFileT; // puntatore alla struct del file di log
threadpool_t *pool; // puntatore alla threadpool
pthread_mutex_t *lock;
waitingT **waiting; // puntatore ai client in attesa di ottenere la lock su un file
} threadT;
// funzione eseguita dal generico Worker del pool di thread
void threadF(void *arg);