diff --git a/src/stasis/io/handle.c b/src/stasis/io/handle.c index 20117dc..0ffc2d0 100644 --- a/src/stasis/io/handle.c +++ b/src/stasis/io/handle.c @@ -31,19 +31,10 @@ static stasis_handle_t * slow_file_factory(void * argsP) { //h = stasis_handle(open_debug)(h); return h; } -static void slow_file_factory_close(void * argsP) { - // nop -} static stasis_handle_t * slow_pfile_factory(void * argsP) { stasis_handle_t * h = argsP; return h; } -static void slow_pfile_factory_close(void * argsP) { - stasis_handle_t * h = argsP; - h->close(h); -} -static int (*slow_close)(stasis_handle_t * h) = 0; -static stasis_handle_t * slow_pfile = 0; static int nop_close(stasis_handle_t*h) { return 0; } stasis_handle_t * stasis_handle(open)(const char * path) { @@ -80,16 +71,16 @@ stasis_handle_t * stasis_handle(open)(const char * path) { int worker_thread_count = 4; if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_PFILE) { // printf("\nusing pread()/pwrite()\n"); - slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm); - slow_close = slow_pfile->close; + stasis_handle_t * slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm); + int (*slow_close)(struct stasis_handle_t *) = slow_pfile->close; slow_pfile->close = nop_close; ret = - stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile_factory_close, slow_pfile, 1, fast_factory, + stasis_handle(open_non_blocking)(slow_pfile_factory, (int(*)(void*))slow_close, slow_pfile, 1, fast_factory, NULL, worker_thread_count, PAGE_SIZE * 1024 , 1024); } else if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_FILE) { ret = - stasis_handle(open_non_blocking)(slow_file_factory, slow_file_factory_close, slow_arg, 0, fast_factory, + stasis_handle(open_non_blocking)(slow_file_factory, 0, slow_arg, 0, fast_factory, NULL, worker_thread_count, PAGE_SIZE * 1024, 1024); } else { printf("Unknown value for config option bufferManagerNonBlockingSlowHandleType\n"); diff --git a/src/stasis/io/non_blocking.c b/src/stasis/io/non_blocking.c index b8fef9b..b1b8e7e 100644 --- a/src/stasis/io/non_blocking.c +++ b/src/stasis/io/non_blocking.c @@ -145,7 +145,7 @@ typedef struct nbw_impl { // Fields to manage slow handles stasis_handle_t * (*slow_factory)(void * arg); - void (*slow_factory_close)(void * arg); + int (*slow_factory_close)(void * arg); void * slow_factory_arg; int slow_force_once; @@ -362,14 +362,14 @@ static int nbw_close(stasis_handle_t * h) { destroyList(&impl->available_slow_handles); free(impl->all_slow_handles); assert(impl->available_slow_handle_count == 0); - + int ret = 0; if(impl->slow_factory_close) { - impl->slow_factory_close(impl->slow_factory_arg); + ret = impl->slow_factory_close(impl->slow_factory_arg); } free(h->impl); free(h); - return 0; + return ret; } static lsn_t nbw_start_position(stasis_handle_t *h) { nbw_impl * impl = h->impl; @@ -783,7 +783,7 @@ static void * nbw_worker(void * handle) { stasis_handle_t * stasis_handle(open_non_blocking) (stasis_handle_t * (*slow_factory)(void * arg), - void (*slow_factory_close)(void * arg), + int (*slow_factory_close)(void * arg), void * slow_factory_arg, int slow_force_once, stasis_handle_t * (*fast_factory)(lsn_t, lsn_t, void *), diff --git a/stasis/io/handle.h b/stasis/io/handle.h index aa487f9..429c7ac 100644 --- a/stasis/io/handle.h +++ b/stasis/io/handle.h @@ -327,7 +327,7 @@ stasis_handle_t * stasis_handle(open_pfile) */ stasis_handle_t * stasis_handle(open_non_blocking) (stasis_handle_t * (*slow_factory)(void * arg), - void (*slow_factory_close)(void * arg), + int (*slow_factory_close)(void * arg), void * slow_factory_arg, int slow_force_once, stasis_handle_t * (*fast_factory)(lsn_t off, lsn_t len, void * arg),