Chunkd: Whole hog on applog
PATCH 2/3 Chunkd: Whole hog on applog
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]>
server/chunkd.h +2 -4
@@ -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 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 const char *fmt, ...)); +struct geo *locp,void (*cb)(enum st_cld ));extern void cld_end (void );/* util.c */
server/cldu.c +5 -8
@@ -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 ;
server/config.c +1 -3
@@ -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);
server/server.c +1 -22
@@ -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; }
Jeff Garzik
AppliedQuoted 5 lines · Pete Zaitcev
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]>
applied