int cstat_load_data_from_disk(struct cstat **clist, struct conf **globalcs, struct conf **cconfs) { if(!globalcs) return -1; return cstat_get_client_names(clist, get_string(globalcs[OPT_CLIENTCONFDIR])) || cstat_reload_from_client_confs(clist, globalcs, cconfs)<0 || reload_from_clientdir(clist)<0; }
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(); }
int cstat_load_data_from_disk(struct cstat **clist, struct conf *conf) { return get_client_names(clist, conf) || reload_from_client_confs(clist, conf) || reload_from_clientdir(clist, conf); }