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]>

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;
        }
 
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to