All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 2/3] Chunkd: Whole hog on applog
@ 2009-08-12 20:56 Pete Zaitcev
  2009-08-12 21:33 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-08-12 20:56 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

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;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch 2/3] Chunkd: Whole hog on applog
  2009-08-12 20:56 [Patch 2/3] Chunkd: Whole hog on applog Pete Zaitcev
@ 2009-08-12 21:33 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-08-12 21:33 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Project Hail List

Pete Zaitcev wrote:
> 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>

applied



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-12 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-12 20:56 [Patch 2/3] Chunkd: Whole hog on applog Pete Zaitcev
2009-08-12 21:33 ` Jeff Garzik

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.