Tabled: Who hog on applog
PATCH 3/3 Tabled: Who 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/cldu.c +3 -18
@@ -56,21 +56,6 @@ static int cldu_put_cb(struct cldc_call_opts *carg, enum cle_err_codes errc);static int cldu_get_1_cb (struct cldc_call_opts *carg,enum cle_err_codes errc);static void add_remote (char *name); -/* The format comes with a trailing newline, but fortunately applog strips it */ -void cldu_p_log (const char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); - -if (use_syslog) -vsyslog (LOG_DEBUG , fmt, ap); -else -vfprintf (stderr, fmt, ap); - -va_end (ap); -} -/* * Identify the next host to be tried. *
@@ -219,7 +204,7 @@ static struct cldc_ops cld_ops = { .timer_ctl = cldu_p_timer_ctl, .pkt_send = cldu_p_pkt_send, .event = cldu_p_event, - .printf = cldu_p_log, + .errlog = applog, };/*
@@ -601,7 +586,7 @@ int cld_begin(const char *thishost, const char *thiscell,GList *tmp, *host_list;int i; -if (cldc_getaddr (&host_list, thishost, debugging, cldu_p_log)) { +if (cldc_getaddr (&host_list, thishost, debugging, applog)) {/* Already logged error */ goto err_addr; }
@@ -683,7 +668,7 @@ void cldu_add_host(const char *hostname, unsigned int port)return ;if (cldc_saveaddr (&hp->h,100 ,100 , port,strlen (hostname), hostname, - debugging, cldu_p_log)) + debugging, applog))return ; hp->known =1 ;
server/server.c +1 -1
@@ -93,7 +93,7 @@ static const struct argp argp = { options, parse_opt, NULL, doc };static bool server_running = true;static bool dump_stats; -bool use_syslog = true; +static bool use_syslog = true;int debugging =0 ;struct server tabled_srv = {
server/tabled.h +0 -1
@@ -282,7 +282,6 @@ int objid_init(void);/* server.c */ extern int debugging; -extern bool use_syslog;extern struct server tabled_srv;extern struct compiled_pat patterns[];extern bool cli_err (struct client *cli,enum errcode code);
server/util.c +8 -5
@@ -97,7 +97,8 @@ int write_pid_file(const char *pid_fn) fd =open (pid_fn,O_WRONLY |O_CREAT ,S_IRUSR |S_IWUSR );if (fd <0 ) { err = errno; -applogerr (pid_fn); +applog (LOG_ERR ,"Cannot open PID file %s: %s" , + pid_fn,strerror (err));return -err; }
@@ -108,10 +109,11 @@ int write_pid_file(const char *pid_fn)if (fcntl (fd,F_SETLK , &lock) !=0 ) { err = errno;if (err ==EAGAIN ) { -applog (LOG_ERR ,"Pid file %s is locked, not starting\n" , +applog (LOG_ERR ,"PID file %s is already locked" , pid_fn); }else { -applogerr (pid_fn); +applog (LOG_ERR ,"Cannot lock PID file %s: %s" , + pid_fn,strerror (err)); }close (fd);return -err;
@@ -124,7 +126,8 @@ int write_pid_file(const char *pid_fn)ssize_t rc =write (fd, s, bytes);if (rc <0 ) { err = errno; -applogerr ("pid data write failed" ); +applog (LOG_ERR ,"PID number write failed: %s" , +strerror (err)); goto err_out; }
@@ -135,7 +138,7 @@ int write_pid_file(const char *pid_fn)/* make sure file data is written to disk */ if (fsync (fd) <0 ) { err = errno; -applogerr ("pid file sync/close failed" ); +applog (LOG_ERR ,"PID file fsync failed: %s" ,strerror (err)); goto err_out; }
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