remove static variables, fix filehandle leak
This commit is contained in:
parent
7b4cf40221
commit
221b2e4acb
3 changed files with 10 additions and 19 deletions
|
@ -31,19 +31,10 @@ static stasis_handle_t * slow_file_factory(void * argsP) {
|
||||||
//h = stasis_handle(open_debug)(h);
|
//h = stasis_handle(open_debug)(h);
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
static void slow_file_factory_close(void * argsP) {
|
|
||||||
// nop
|
|
||||||
}
|
|
||||||
static stasis_handle_t * slow_pfile_factory(void * argsP) {
|
static stasis_handle_t * slow_pfile_factory(void * argsP) {
|
||||||
stasis_handle_t * h = argsP;
|
stasis_handle_t * h = argsP;
|
||||||
return h;
|
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; }
|
static int nop_close(stasis_handle_t*h) { return 0; }
|
||||||
|
|
||||||
stasis_handle_t * stasis_handle(open)(const char * path) {
|
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;
|
int worker_thread_count = 4;
|
||||||
if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_PFILE) {
|
if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_PFILE) {
|
||||||
// printf("\nusing pread()/pwrite()\n");
|
// printf("\nusing pread()/pwrite()\n");
|
||||||
slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm);
|
stasis_handle_t * slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm);
|
||||||
slow_close = slow_pfile->close;
|
int (*slow_close)(struct stasis_handle_t *) = slow_pfile->close;
|
||||||
slow_pfile->close = nop_close;
|
slow_pfile->close = nop_close;
|
||||||
ret =
|
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);
|
NULL, worker_thread_count, PAGE_SIZE * 1024 , 1024);
|
||||||
|
|
||||||
} else if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_FILE) {
|
} else if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_FILE) {
|
||||||
ret =
|
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);
|
NULL, worker_thread_count, PAGE_SIZE * 1024, 1024);
|
||||||
} else {
|
} else {
|
||||||
printf("Unknown value for config option bufferManagerNonBlockingSlowHandleType\n");
|
printf("Unknown value for config option bufferManagerNonBlockingSlowHandleType\n");
|
||||||
|
|
|
@ -145,7 +145,7 @@ typedef struct nbw_impl {
|
||||||
|
|
||||||
// Fields to manage slow handles
|
// Fields to manage slow handles
|
||||||
stasis_handle_t * (*slow_factory)(void * arg);
|
stasis_handle_t * (*slow_factory)(void * arg);
|
||||||
void (*slow_factory_close)(void * arg);
|
int (*slow_factory_close)(void * arg);
|
||||||
void * slow_factory_arg;
|
void * slow_factory_arg;
|
||||||
int slow_force_once;
|
int slow_force_once;
|
||||||
|
|
||||||
|
@ -362,14 +362,14 @@ static int nbw_close(stasis_handle_t * h) {
|
||||||
destroyList(&impl->available_slow_handles);
|
destroyList(&impl->available_slow_handles);
|
||||||
free(impl->all_slow_handles);
|
free(impl->all_slow_handles);
|
||||||
assert(impl->available_slow_handle_count == 0);
|
assert(impl->available_slow_handle_count == 0);
|
||||||
|
int ret = 0;
|
||||||
if(impl->slow_factory_close) {
|
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->impl);
|
||||||
free(h);
|
free(h);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
static lsn_t nbw_start_position(stasis_handle_t *h) {
|
static lsn_t nbw_start_position(stasis_handle_t *h) {
|
||||||
nbw_impl * impl = h->impl;
|
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 * stasis_handle(open_non_blocking)
|
||||||
(stasis_handle_t * (*slow_factory)(void * arg),
|
(stasis_handle_t * (*slow_factory)(void * arg),
|
||||||
void (*slow_factory_close)(void * arg),
|
int (*slow_factory_close)(void * arg),
|
||||||
void * slow_factory_arg,
|
void * slow_factory_arg,
|
||||||
int slow_force_once,
|
int slow_force_once,
|
||||||
stasis_handle_t * (*fast_factory)(lsn_t, lsn_t, void *),
|
stasis_handle_t * (*fast_factory)(lsn_t, lsn_t, void *),
|
||||||
|
|
|
@ -327,7 +327,7 @@ stasis_handle_t * stasis_handle(open_pfile)
|
||||||
*/
|
*/
|
||||||
stasis_handle_t * stasis_handle(open_non_blocking)
|
stasis_handle_t * stasis_handle(open_non_blocking)
|
||||||
(stasis_handle_t * (*slow_factory)(void * arg),
|
(stasis_handle_t * (*slow_factory)(void * arg),
|
||||||
void (*slow_factory_close)(void * arg),
|
int (*slow_factory_close)(void * arg),
|
||||||
void * slow_factory_arg,
|
void * slow_factory_arg,
|
||||||
int slow_force_once,
|
int slow_force_once,
|
||||||
stasis_handle_t * (*fast_factory)(lsn_t off, lsn_t len, void * arg),
|
stasis_handle_t * (*fast_factory)(lsn_t off, lsn_t len, void * arg),
|
||||||
|
|
Loading…
Reference in a new issue