All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 2/3] Chunkd: Whole hog on applog
Date: Wed, 12 Aug 2009 14:56:05 -0600	[thread overview]
Message-ID: <20090812145605.1dc73732@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/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;
 	}

             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:33 ` [Patch 2/3] Chunkd: Whole 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=20090812145605.1dc73732@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.