more non_blocking fixes. now the unit test passes
This commit is contained in:
parent
774ccfb002
commit
4a5d14f2c6
2 changed files with 18 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include <stasis/common.h>
|
||||
|
||||
#undef STLSEARCH // XXX
|
||||
|
@ -366,7 +367,7 @@ static int nbw_close(stasis_handle_t * h) {
|
|||
pthread_mutex_destroy(&impl->mut);
|
||||
stasis_handle_t * slow;
|
||||
while(-1 != (long)(slow = (stasis_handle_t*)popMaxVal(&impl->available_slow_handles))) {
|
||||
slow->close(slow);
|
||||
if(!impl->slow_factory_close) slow->close(slow);
|
||||
impl->available_slow_handle_count--;
|
||||
}
|
||||
destroyList(&impl->available_slow_handles);
|
||||
|
@ -847,7 +848,7 @@ stasis_handle_t * stasis_handle(open_non_blocking)
|
|||
pthread_cond_init(&impl->force_completed_cond, 0);
|
||||
|
||||
impl->still_open = 1;
|
||||
impl->refcount++;
|
||||
impl->refcount = 1;
|
||||
|
||||
stasis_handle_t *h = malloc(sizeof(stasis_handle_t));
|
||||
*h = nbw_func;
|
||||
|
|
|
@ -428,9 +428,13 @@ static stasis_handle_t * slow_factory_file(void * argsP) {
|
|||
sf_args * args = (sf_args*) argsP;
|
||||
return stasis_handle(open_file)(0, args->filename, args->openMode, args->filePerm);
|
||||
}
|
||||
static stasis_handle_t * slow_factory_pfile(void * argsP) {
|
||||
sf_args * args = (sf_args*) argsP;
|
||||
return stasis_handle(open_pfile)(0, args->filename, args->openMode, args->filePerm);
|
||||
static stasis_handle_t * slow_pfile_factory(void * argsP) {
|
||||
stasis_handle_t * h = argsP;
|
||||
return h;
|
||||
}
|
||||
static int slow_pfile_close(void * argsP) {
|
||||
stasis_handle_t * h = argsP;
|
||||
return h->close(h);
|
||||
}
|
||||
|
||||
START_TEST(io_nonBlockingTest_file) {
|
||||
|
@ -482,7 +486,9 @@ START_TEST(io_nonBlockingTest_pfile) {
|
|||
FILE_PERM
|
||||
};
|
||||
|
||||
h = stasis_handle(open_non_blocking)(slow_factory_pfile, 0, &slow_args, 0,
|
||||
stasis_handle_t * pfile_singleton = slow_factory_file(&slow_args);
|
||||
|
||||
h = stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile_close, pfile_singleton, 0,
|
||||
fast_factory, 0,
|
||||
5, 1024*1024, 100);
|
||||
// h = stasis_handle(open_debug)(h);
|
||||
|
@ -491,7 +497,8 @@ START_TEST(io_nonBlockingTest_pfile) {
|
|||
|
||||
unlink("logfile.txt");
|
||||
|
||||
h = stasis_handle(open_non_blocking)(slow_factory_pfile, 0, &slow_args, 0,
|
||||
pfile_singleton = slow_factory_file(&slow_args);
|
||||
h = stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile_close, pfile_singleton, 0,
|
||||
fast_factory, 0,
|
||||
5, 1024*1024, 100);
|
||||
//h = stasis_handle(open_debug)(h);
|
||||
|
@ -500,7 +507,8 @@ START_TEST(io_nonBlockingTest_pfile) {
|
|||
|
||||
unlink("logfile.txt");
|
||||
|
||||
h = stasis_handle(open_non_blocking)(slow_factory_pfile, 0, &slow_args, 0,
|
||||
pfile_singleton = slow_factory_file(&slow_args);
|
||||
h = stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile_close, pfile_singleton, 0,
|
||||
fast_factory, 0,
|
||||
5, 1024 * 1024, 100);
|
||||
handle_concurrencytest(h);
|
||||
|
@ -521,12 +529,11 @@ Suite * check_suite(void) {
|
|||
// tcase_set_timeout(tc, 1800); // thirty minute timeout
|
||||
|
||||
/* Sub tests are added, one per line, here */
|
||||
tcase_add_test(tc, io_nonBlockingTest_pfile);
|
||||
tcase_add_test(tc, io_memoryTest);
|
||||
tcase_add_test(tc, io_fileTest);
|
||||
tcase_add_test(tc, io_pfileTest);
|
||||
tcase_add_test(tc, io_nonBlockingTest_file);
|
||||
(void)io_nonBlockingTest_pfile; // XXX fails due to bug in test (or in pfile?)
|
||||
// tcase_add_test(tc, io_nonBlockingTest_pfile);
|
||||
/* --------------------------------------------- */
|
||||
tcase_add_checked_fixture(tc, setup, teardown);
|
||||
suite_add_tcase(s, tc);
|
||||
|
|
Loading…
Reference in a new issue