Api for managing files
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
#include <apiFile.h>
|
||||
|
||||
|
||||
void openFile(char *filepath, int flags, queueT *q, long fd_c, logT *logFileT);
|
||||
|
||||
|
||||
void readFile(char *filepath, queueT *q, long fd_c, logT *logFileT);
|
||||
|
||||
|
||||
void readNFiles(char *numStr, queueT *q, long fd_c, logT *logFileT);
|
||||
|
||||
|
||||
void writeFile(char *filepath, size_t size, queueT *q, long fd_c, logT *logFileT, int append);
|
||||
|
||||
|
||||
void lockFile(char *filepath, queueT *q, long fd_c, logT *logFileT, pthread_mutex_t *lock, waitingT **waiting);
|
||||
|
||||
|
||||
void unlockFile(char *filepath, queueT *q, long fd_c, logT *logFileT, pthread_mutex_t *lock, waitingT **waiting);
|
||||
|
||||
|
||||
void closeFile(char *filepath, queueT *q, long fd_c, logT *logFileT, pthread_mutex_t *lock, waitingT **waiting);
|
||||
|
||||
|
||||
void removeFile(char *filepath, queueT *q, long fd_c, logT *logFileT, pthread_mutex_t *lock, waitingT **waiting);
|
||||
|
||||
|
||||
|
||||
int sendFile(fileT *f, long fd_c, logT *logFileT);
|
||||
|
||||
|
||||
int addWaiting(waitingT **waiting, char *file, int fd);
|
||||
|
||||
|
||||
int removeFirstWaiting(waitingT **waiting, char *file);
|
||||
|
||||
|
||||
void clearWaiting(waitingT **waiting);
|
||||
|
||||
@ -6,6 +6,13 @@
|
||||
/* TODO: include lib di logging */
|
||||
/* TODO: finire tutte le descrizioni */
|
||||
|
||||
// Lista dei client in attesa su una lock
|
||||
typedef struct struct_waiting {
|
||||
long fd; // client in attesa
|
||||
char *file; // file su cui si vuole acquisire la lock
|
||||
struct struct_waiting *next; // puntatore al prossimo elemento della lista
|
||||
} waitingT;
|
||||
|
||||
/**
|
||||
* Apri o crea un nuovo file
|
||||
* \param filepath: nome del file
|
||||
|
||||
@ -34,7 +34,6 @@ static void *workerpool_thread(void *threadpool) {
|
||||
|
||||
LOCK_RETURN(&(pool->lock), NULL);
|
||||
for (;;) {
|
||||
|
||||
// in attesa di un messaggio, controllo spurious wakeups.
|
||||
while((pool->count == 0) && (!pool->exiting)) {
|
||||
pthread_cond_wait(&(pool->cond), &(pool->lock));
|
||||
|
||||
Reference in New Issue
Block a user