From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 3/3] Tabled: Who hog on applog
Date: Wed, 12 Aug 2009 14:56:11 -0600 [thread overview]
Message-ID: <20090812145611.7711fa30@redhat.com> (raw)
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 <zaitcev@redhat.com>
diff --git a/server/cldu.c b/server/cldu.c
index a9ac59b..9ce61b7 100644
--- a/server/cldu.c
+++ b/server/cldu.c
@@ -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;
diff --git a/server/server.c b/server/server.c
index 31ea399..b3d59bf 100644
--- a/server/server.c
+++ b/server/server.c
@@ -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 = {
diff --git a/server/tabled.h b/server/tabled.h
index 4dd56b4..d12d032 100644
--- a/server/tabled.h
+++ b/server/tabled.h
@@ -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);
diff --git a/server/util.c b/server/util.c
index f4f6612..508b517 100644
--- a/server/util.c
+++ b/server/util.c
@@ -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;
}
next reply other threads:[~2009-08-12 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-12 20:56 Pete Zaitcev [this message]
2009-08-12 21:36 ` [Patch 3/3] Tabled: Who hog on applog Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090812145611.7711fa30@redhat.com \
--to=zaitcev@redhat.com \
--cc=hail-devel@vger.kernel.org \
--cc=jeff@garzik.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.