// The return code of this is the return code of the standalone process. int champ_chooser_server_standalone(struct conf **globalcs) { int ret=1; struct sdirs *sdirs=NULL; struct conf **cconfs=NULL; const char *orig_client=get_string(globalcs[OPT_ORIG_CLIENT]); if(!(cconfs=confs_alloc())) goto end; confs_init(cconfs); // We need to be given a client name and load the relevant server side // clientconfdir file, because various settings may be overridden // there. if(set_string(cconfs[OPT_CNAME], orig_client) || conf_load_clientconfdir(globalcs, cconfs) || !(sdirs=sdirs_alloc()) || sdirs_init_from_confs(sdirs, cconfs) || champ_chooser_server(sdirs, cconfs, 0 /* resume */)) goto end; ret=0; end: confs_free(&cconfs); sdirs_free(&sdirs); return ret; }
static void tear_down(struct cstat **cstat) { sdirs_free((struct sdirs **)&(*cstat)->sdirs); cstat_free(cstat); alloc_check(); clean(); }
extern int sdirs_init(struct sdirs *sdirs, struct conf *conf) { if(!conf->directory) { logp("conf->directory unset in %s\n", __func__); goto error; } if(!(sdirs->base=strdup(conf->directory))) goto error; if(conf->protocol==PROTO_BURP1) { if(do_burp1_dirs(sdirs, conf)) goto error; } else { if(do_v2_dirs(sdirs, conf)) goto error; } if(do_lock_dirs(sdirs, conf)) goto error; return 0; error: sdirs_free(sdirs); return -1; }
END_TEST static void cstat_list_free_sdirs(struct cstat *clist) { struct cstat *c; for(c=clist; c; c=c->next) sdirs_free((struct sdirs **)&c->sdirs); }
static void tear_down(struct asfd **asfd, struct sdirs **sdirs) { asfd_free(asfd); asfd_mock_teardown(&reads, &writes); sdirs_free(sdirs); fail_unless(recursive_delete(BASE)==0); alloc_check(); }
static void tear_down(struct fdirs **fdirs, struct sdirs **sdirs, struct conf ***confs) { fdirs_free(fdirs); sdirs_free(sdirs); confs_free(confs); alloc_check(); }
static void tear_down( struct sdirs **sdirs, struct fdirs **fdirs, struct conf ***confs) { sdirs_free(sdirs); fdirs_free(fdirs); confs_free(confs); fail_unless(!recursive_delete(BASE)); alloc_check(); }
static void tear_down(struct async **as, struct sdirs **sdirs, struct conf ***confs) { async_free(as); sdirs_free(sdirs); confs_free(confs); fail_unless(!recursive_delete(BASE)); //printf("%d %d\n", alloc_count, free_count); alloc_check(); }
END_TEST static void do_test_cstat_reload_from_client_confs(enum protocol protocol) { struct cstat *c1; struct cstat *c2; struct cstat *clist=NULL; c1=setup_cstat("cli1", protocol); c2=setup_cstat("cli2", protocol); cstat_add_to_list(&clist, c1); cstat_add_to_list(&clist, c2); c1->permitted=1; // First time, nothing is reloaded. fail_unless(reload_from_clientdir(&clist)==0); fail_unless(c1->run_status==RUN_STATUS_IDLE); fail_unless(c2->run_status==RUN_STATUS_UNSET); fail_unless(c1->bu==NULL); fail_unless(c2->bu==NULL); // Add some storage dirs, and c1 is loaded. build_storage_dirs((struct sdirs *)c1->sdirs, sd123, ARR_LEN(sd123)); fail_unless(reload_from_clientdir(&clist)==1); fail_unless(c1->run_status==RUN_STATUS_IDLE); fail_unless(c2->run_status==RUN_STATUS_UNSET); fail_unless(c1->bu!=NULL); fail_unless(c2->bu==NULL); // Go again, nothing should be reloaded. fail_unless(reload_from_clientdir(&clist)==0); // Get a lock. lock_get_quick(((struct sdirs *)c1->sdirs)->lock); fail_unless(reload_from_clientdir(&clist)==1); sdirs_free((struct sdirs **)&c1->sdirs); sdirs_free((struct sdirs **)&c2->sdirs); cstat_list_free(&clist); clean(); alloc_check(); }
static void tear_down(struct async **as, struct asfd **asfd, struct sdirs **sdirs, struct conf ***confs) { async_free(as); asfd_free(asfd); sdirs_free(sdirs); asfd_mock_teardown(&reads, &writes); confs_free(confs); //printf("%d %d\n", alloc_count, free_count); alloc_check(); }
int run_action_server(struct async *as, const char *incexc, int srestore, int *timer_ret, struct conf **cconfs) { int ret=-1; struct sdirs *sdirs=NULL; if((sdirs=sdirs_alloc()) && !sdirs_init_from_confs(sdirs, cconfs)) ret=run_action_server_do(as, sdirs, incexc, srestore, timer_ret, cconfs); if(sdirs) lock_release(sdirs->lock); sdirs_free(&sdirs); return ret; }
static int set_cstat_from_conf(struct cstat *cstat, struct conf **parentconfs, struct conf **cconfs) { struct strlist *s=NULL; // Make sure the permitted flag is set appropriately. cstat->permitted=cstat_permitted(cstat, parentconfs, cconfs); cstat->protocol=get_protocol(cconfs); sdirs_free((struct sdirs **)&cstat->sdirs); if(!(cstat->sdirs=sdirs_alloc()) || sdirs_init_from_confs((struct sdirs *)cstat->sdirs, cconfs)) return -1; strlists_free(&cstat->labels); for(s=get_strlist(cconfs[OPT_LABEL]); s; s=s->next) if(strlist_add_sorted(&cstat->labels, s->path, s->flag)) return -1; return 0; }
static void cstat_free_w(struct cstat **cstat) { sdirs_free((struct sdirs **)&(*cstat)->sdirs); cstat_free(cstat); }