diff --git a/Makefile b/Makefile index 0ffbde1..d282153 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CFLAGS = -Wall -Wextra -ggdb -fsanitize=address,undefined +CFLAGS = -Wall -Wextra -ggdb ifeq ($(OS),Windows_NT) LFLAGS = -lws2_32 diff --git a/src/client.c b/src/client.c index 107445f..f06474d 100644 --- a/src/client.c +++ b/src/client.c @@ -219,8 +219,10 @@ alloc_operation(TinyDFS *tdfs, OperationType type, int off, void *ptr, int len) if (tdfs->num_operations == MAX_OPERATIONS) return -1; Operation *o = tdfs->operations; - while (o->type != OPERATION_TYPE_FREE) + while (o - tdfs->operations < MAX_OPERATIONS && o->type != OPERATION_TYPE_FREE) o++; + if (o - tdfs->operations >= MAX_OPERATIONS) + return -1; o->type = type; o->ptr = ptr; o->off = off; @@ -418,7 +420,7 @@ int tinydfs_submit_create(TinyDFS *tdfs, char *path, int path_len, return -1; } - return 0; + return opidx; } int tinydfs_submit_delete(TinyDFS *tdfs, char *path, int path_len) @@ -444,7 +446,7 @@ int tinydfs_submit_delete(TinyDFS *tdfs, char *path, int path_len) return -1; } - return 0; + return opidx; } int tinydfs_submit_list(TinyDFS *tdfs, char *path, int path_len) @@ -471,7 +473,7 @@ int tinydfs_submit_list(TinyDFS *tdfs, char *path, int path_len) return -1; } - return 0; + return opidx; } static int send_read_message(TinyDFS *tdfs, int opidx, int tag, string path, uint32_t offset, uint32_t length) @@ -504,7 +506,7 @@ int tinydfs_submit_read(TinyDFS *tdfs, char *path, int path_len, int off, void * return -1; } - return 0; + return opidx; } int tinydfs_submit_write(TinyDFS *tdfs, char *path, int path_len, int off, void *src, int len) @@ -522,7 +524,7 @@ int tinydfs_submit_write(TinyDFS *tdfs, char *path, int path_len, int off, void return -1; } - return 0; + return opidx; } void tinydfs_result_free(TinyDFS_Result *result) diff --git a/src/simulation_client.h b/src/simulation_client.h index abf1caf..6d4bb05 100644 --- a/src/simulation_client.h +++ b/src/simulation_client.h @@ -12,7 +12,7 @@ #include "TinyDFS.h" -#define MAX_PENDING_OPERATION 128 +#define MAX_PENDING_OPERATION 8 typedef enum { PENDING_OPERATION_CREATE,