working -u -l -c
This commit is contained in:
2
Makefile
2
Makefile
@ -100,7 +100,7 @@ print-%: ; @echo $* = $($*)
|
|||||||
# -TESTS------------------------------------------------------------------------
|
# -TESTS------------------------------------------------------------------------
|
||||||
|
|
||||||
test1: all
|
test1: all
|
||||||
@echo "[threadpool]\n\nquantity = 1\npending = 10\n\n[files]\n\nMaxFiles = 10000\nMaxSize = 128000\n\n[log]\n\nlogFile = ./logs/l.log\n\n[socket]\n\nname = ./socket\nbacklog = 100\n" > build/confix.txt
|
@echo "[threadpool]\n\nquantity = 1\npending = 10\n\n[files]\n\nMaxFiles = 10000\nMaxSize = 128000000\n\n[log]\n\nlogFile = ./logs/l.log\n\n[socket]\n\nname = ./socket\nbacklog = 100\n" > build/confix.txt
|
||||||
valgrind --leak-check=full --track-origins=yes $(BUILD_DIR)/server &
|
valgrind --leak-check=full --track-origins=yes $(BUILD_DIR)/server &
|
||||||
bash scripts/test1.sh
|
bash scripts/test1.sh
|
||||||
pkill -1 memcheck-amd64
|
pkill -1 memcheck-amd64
|
||||||
|
|||||||
@ -1147,7 +1147,8 @@ int removeFile(const char* pathname) {
|
|||||||
} else {
|
} else {
|
||||||
openedFiles->numOfFiles--;
|
openedFiles->numOfFiles--;
|
||||||
}
|
}
|
||||||
|
freeResponse(res);
|
||||||
|
free(res);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -733,7 +733,7 @@ void removeFile(char *filepath, queueT *q, long fd_c, taglia_t *taglia, pthread_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (removeFileFromQueue(q, filepath, fd_c) == -1) {
|
if (removeFileFromQueue(q, filepath, fd_c) == -1) {
|
||||||
n += snprintf(tmp_buf+n, m-n, "Client %ld ha richiesto una removeFile sul file \"%s\" e' terminata con errore.\n", fd_c, filepath);
|
n += snprintf(tmp_buf+n, m-n, "Client %ld ha richiesto una removeFile sul file \"%s\" e' terminata con errore del server.\n", fd_c, filepath);
|
||||||
serror(MENT, fd_c, taglia, tmp_buf);
|
serror(MENT, fd_c, taglia, tmp_buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -682,8 +682,8 @@ int removeFileFromQueue(queueT *q, char *filepath, int owner) {
|
|||||||
goto _end_remove_file_queue;
|
goto _end_remove_file_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tmp->data)->open != 0 || ((tmp->data)->O_LOCK && (tmp->data)->owner != owner)) {
|
if (((tmp->data)->O_LOCK) && ((tmp->data)->owner != owner)) {
|
||||||
// if file è aperto o la lock non è del owner
|
// if lock non è del owner
|
||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
goto _end_remove_file_queue;
|
goto _end_remove_file_queue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
./client -t 200 -f socket -w testFiles/1 -D Wdir -W testFiles/1/file1 -r testFiles/1/file1 -d Rdir -R n=3 -p
|
./build/client -t 200 -f socket -w testFiles/1 -D Wdir -W testFiles/1/file1 -r testFiles/1/file1 -d Rdir -R n=3 -p
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
@ -838,9 +838,9 @@ int cmd_u(char *filelist, int print) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we copy filelist because we are nice
|
// we copy filelist because we are nice
|
||||||
char *tofree = malloc(strnlen(filelist, MAXARGLENGTH)+1);
|
char *tofree = calloc(strnlen(filelist, MAXARGLENGTH)+1, sizeof(char));
|
||||||
if(!tofree) {
|
if(!tofree) {
|
||||||
perror("malloc");
|
perror("calloc");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tofree, filelist, strnlen(filelist, MAXARGLENGTH));
|
strncpy(tofree, filelist, strnlen(filelist, MAXARGLENGTH));
|
||||||
@ -884,9 +884,9 @@ int cmd_c(char *filelist, int print) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we copy filelist because we are nice
|
// we copy filelist because we are nice
|
||||||
char *tofree = malloc(strnlen(filelist, MAXARGLENGTH)+1);
|
char *tofree = calloc(strnlen(filelist, MAXARGLENGTH)+1, sizeof(char));
|
||||||
if(!tofree) {
|
if(!tofree) {
|
||||||
perror("malloc");
|
perror("calloc");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tofree, filelist, strnlen(filelist, MAXARGLENGTH));
|
strncpy(tofree, filelist, strnlen(filelist, MAXARGLENGTH));
|
||||||
|
|||||||
Reference in New Issue
Block a user