From fea8af9b11b500a45344f836055d39963204878f Mon Sep 17 00:00:00 2001 From: ln-tech Date: Wed, 13 Nov 2019 07:45:57 +0100 Subject: SIGINT fix, Reader-Writer oroblem fix --- src/fuse/main.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/fuse/main.c') diff --git a/src/fuse/main.c b/src/fuse/main.c index 666ff6c..175cbb2 100644 --- a/src/fuse/main.c +++ b/src/fuse/main.c @@ -14,7 +14,7 @@ #include "../shared/log.h" #define FUSE_USE_VERSION 30 -#include +#include "../config.h" #include #include #include @@ -48,6 +48,19 @@ static uid_t owner; static void (*fuse_sigIntHandler)(int) = NULL; static void (*fuse_sigTermHandler)(int) = NULL; +static int reply_buf_limited(fuse_req_t req, const char *buf, size_t bufsize, off_t off, size_t maxsize); +static int fillStatsFile(char *buf, size_t size, off_t offset); +static void image_destroy(void *private_data); +static void image_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); +static void image_ll_init(void *userdata, struct fuse_conn_info *conn); +static void image_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name); +static void image_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); +static void image_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi); +static void image_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t offset, struct fuse_file_info *fi); +static int image_stat(fuse_ino_t ino, struct stat *stbuf); +static void printUsage(char *argv0, int exitCode); +static void printVersion(); + static int image_stat(fuse_ino_t ino, struct stat *stbuf) { stbuf->st_ctim = stbuf->st_atim = stbuf->st_mtim = startupTime; @@ -226,6 +239,7 @@ static void image_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off ++logInfo.blockRequestCount[startBlock]; } } + if (ino == 2 && size != 0) // with size == 0 there is nothing to do { dnbd3_async_t *request = malloc(sizeof(dnbd3_async_t)); @@ -239,7 +253,10 @@ static void image_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off } static void image_sigHandler(int signum) { - //keepRunning = false; + pthread_mutex_lock( &mutexInit ); + keepRunning = false; + pthread_mutex_unlock( &mutexInit ); + //printf("\n hallo222 %d", keepRunning); if ( signum == SIGINT && fuse_sigIntHandler != NULL ) { fuse_sigIntHandler(signum); } @@ -318,8 +335,13 @@ flags contains FUSE_BUF_SPLICE_MOVE struct sigaction newHandler; memset( &newHandler, 0, sizeof(newHandler) ); newHandler.sa_handler = &image_sigHandler; + //newHandler.sa_flags &= ~SA_RESTART; + newHandler.sa_flags |= SA_RESETHAND; sigemptyset( &newHandler.sa_mask ); + //rt_sigaction(sa_flags=SA_RESTORER|SA_ONSTACK|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|SA_SIGINFO|SA_NOCLDSTOP|SA_NOCLDWAIT|0x3fffff8 struct sigaction oldHandler; + //oldHandler.sa_flags &= ~SA_RESTART; + //oldHandler.sa_flags |= SA_RESETHAND; // Retrieve old handlers when setting sigaction( SIGINT, &newHandler, &oldHandler ); fuse_sigIntHandler = oldHandler.sa_handler; -- cgit v1.2.3-55-g7522