We abandon the wasteful strategy of gradual changes and simply change to applog-style API wholesale, to put the whole issue behind. Applications need to be rebuilt after new cld-devel is installed.
Signed-off-by: Pete Zaitcev <[email protected]> diff --git a/server/chunkd.h b/server/chunkd.h index 82b8b97..754c250 100644 --- a/server/chunkd.h +++ b/server/chunkd.h @@ -191,11 +191,9 @@ extern void cli_out_end(struct client *cli); extern void cli_in_end(struct client *cli); /* cldu.c */ -extern void cldu_add_host(const char *host, unsigned int port, - void print(const char *fmt, ...)); +extern void cldu_add_host(const char *host, unsigned int port); extern int cld_begin(const char *thishost, const char *thiscell, uint32_t nid, - struct geo *locp, void (*cb)(enum st_cld), - void print(const char *fmt, ...)); + struct geo *locp, void (*cb)(enum st_cld)); extern void cld_end(void); /* util.c */ diff --git a/server/cldu.c b/server/cldu.c index 1ab4f77..fc746e4 100644 --- a/server/cldu.c +++ b/server/cldu.c @@ -205,6 +205,7 @@ static struct cldc_ops cld_ops = { .timer_ctl = cldu_p_timer_ctl, .pkt_send = cldu_p_pkt_send, .event = cldu_p_event, + .errlog = applog, }; /* @@ -566,12 +567,9 @@ static struct cld_session ses; * (the time between cld_begin and cld_end). */ int cld_begin(const char *thishost, const char *thiscell, uint32_t nid, - struct geo *locp, void (*cb)(enum st_cld), - void log(const char *fmt, ...)) + struct geo *locp, void (*cb)(enum st_cld)) { - cld_ops.printf = log; - if (!nid) return 0; cldc_init(); @@ -593,7 +591,7 @@ int cld_begin(const char *thishost, const char *thiscell, uint32_t nid, GList *tmp, *host_list = NULL; int i; - if (cldc_getaddr(&host_list, thishost, debugging, log)) { + if (cldc_getaddr(&host_list, thishost, debugging, applog)) { /* Already logged error */ goto err_addr; } @@ -663,8 +661,7 @@ void cld_end(void) free(ses.ffname); } -void cldu_add_host(const char *hostname, unsigned int port, - void log(const char *fmt, ...)) +void cldu_add_host(const char *hostname, unsigned int port) { static struct cld_session *sp = &ses; struct cld_host *hp; @@ -679,7 +676,7 @@ void cldu_add_host(const char *hostname, unsigned int port, return; if (cldc_saveaddr(&hp->h, 100, 100, port, strlen(hostname), hostname, - debugging, log)) + debugging, applog)) return; hp->known = 1; diff --git a/server/config.c b/server/config.c index dc97587..6218dd2 100644 --- a/server/config.c +++ b/server/config.c @@ -19,8 +19,6 @@ #include <glib.h> #include "chunkd.h" -void app_log(const char *fmt, ...); /* FIXME: get rid of this */ - struct config_context { char *text; bool badnid; @@ -202,7 +200,7 @@ static void cfg_elm_end_cld(struct config_context *cc) goto end; } - cldu_add_host(cc->cld_host, cc->cld_port, app_log); + cldu_add_host(cc->cld_host, cc->cld_port); end: free(cc->cld_host); diff --git a/server/server.c b/server/server.c index 3e7016e..15ac4f1 100644 --- a/server/server.c +++ b/server/server.c @@ -123,27 +123,6 @@ static struct { "Cookie check failed" }, }; -/* FIXME static */ void app_log(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - if (use_syslog) { - vsyslog(LOG_DEBUG, fmt, ap); - } else { - char *f; - int len; - int pid; - - pid = getpid() & 0xFFFFFFFF; - len = sizeof(PROGRAM_NAME "[0123456789]: ") + strlen(fmt) + 2; - f = alloca(len); - sprintf(f, PROGRAM_NAME "[%u]: %s\n", pid, fmt); - vfprintf(stderr, f, ap); /* atomic write to stderr */ - } - va_end(ap); -} - void applog(int prio, const char *fmt, ...) { va_list ap; @@ -1245,7 +1224,7 @@ int main (int argc, char *argv[]) chunkd_srv.trash_sz = 0; if (cld_begin(chunkd_srv.ourhost, chunkd_srv.cell, chunkd_srv.nid, - &chunkd_srv.loc, NULL, app_log)) { + &chunkd_srv.loc, NULL)) { rc = 1; goto err_out_session; } -- To unsubscribe from this list: send the line "unsubscribe hail-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
