working -u -l -c

This commit is contained in:
elvis
2022-04-30 00:37:59 +02:00
parent 6bf73e8d18
commit 85231d073f
6 changed files with 11 additions and 10 deletions

View File

@ -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

View File

@ -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;
} }

View File

@ -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;
} }

View File

@ -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;
} }

View File

@ -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

View File

@ -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));