The branch, 1.0.46 has been updated
       via  cac693b5333227e73a66fcc076e44625e5cc0614 (commit)
       via  d1d51b8822bfe3f7dc4c45a967ea4645975251de (commit)
      from  d94e76bfb3e464c0540331caf282efc13ff60e42 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=1.0.46


- Log -----------------------------------------------------------------
commit cac693b5333227e73a66fcc076e44625e5cc0614
Author: Ronnie Sahlberg <[EMAIL PROTECTED]>
Date:   Fri Oct 17 08:19:35 2008 +1100

    use 46_1 instead of 46-1 as the patchlevel

commit d1d51b8822bfe3f7dc4c45a967ea4645975251de
Author: Ronnie Sahlberg <[EMAIL PROTECTED]>
Date:   Fri Oct 17 08:17:12 2008 +1100

    specify a "script log level" on the commandline to set under which log
    level any/all output from eventscripts will be logged as

-----------------------------------------------------------------------

Summary of changes:
 include/ctdb_private.h  |    2 ++
 packaging/RPM/ctdb.spec |    5 ++++-
 server/ctdb_logging.c   |   45 ++++++++++++++++++++++++++-------------------
 server/ctdbd.c          |    6 ++++++
 4 files changed, 38 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 4124f64..5bcb72e 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1344,4 +1344,6 @@ int ctdb_control_reload_nodes_file(struct ctdb_context 
*ctdb, uint32_t opcode);
 int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
 int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb, TDB_DATA 
*outdata);
 
+extern int script_log_level;
+
 #endif
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index 372781d..440364c 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -5,7 +5,7 @@ Vendor: Samba Team
 Packager: Samba Team <[EMAIL PROTECTED]>
 Name: ctdb
 Version: 1.0
-Release: 46
+Release: 46_1
 Epoch: 0
 License: GNU GPL version 3
 Group: System Environment/Daemons
@@ -120,6 +120,9 @@ fi
 %{_includedir}/ctdb_private.h
 
 %changelog
+* Fri Oct 17 2008 : Version 1.0.46-1
+ - Backport bugfix for logging of multiple lines at a time.
+ - Add --script-log-level to control how eventscript/rc.local output is to be 
logged
 * Thu Jul 10 2008 : Version 1.0.46
  - Document both the LVS:cingle-ip-address and the REMOTE-NODE:wan-accelerator
    capabilities.
diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
index 6ebc8c1..06c7eb8 100644
--- a/server/ctdb_logging.c
+++ b/server/ctdb_logging.c
@@ -138,38 +138,45 @@ static void ctdb_log_handler(struct event_context *ev, 
struct fd_event *fde,
                             uint16_t flags, void *private)
 {
        struct ctdb_context *ctdb = talloc_get_type(private, struct 
ctdb_context);
-       int n1, n2;
        char *p;
+       int n;
 
        if (!(flags & EVENT_FD_READ)) {
                return;
        }
        
-       n1 = read(ctdb->log->pfd, &ctdb->log->buf[ctdb->log->buf_used],
+       n = read(ctdb->log->pfd, &ctdb->log->buf[ctdb->log->buf_used],
                 sizeof(ctdb->log->buf) - ctdb->log->buf_used);
-       if (n1 > 0) {
-               ctdb->log->buf_used += n1;
+       if (n > 0) {
+               ctdb->log->buf_used += n;
        }
 
-       p = memchr(ctdb->log->buf, '\n', ctdb->log->buf_used);
-       if (!p) {
-               if (ctdb->log->buf_used == sizeof(ctdb->log->buf)) {
-                       do_debug("%*.*s\n", 
-                                (int)ctdb->log->buf_used, 
(int)ctdb->log->buf_used, ctdb->log->buf);
-                       ctdb->log->buf_used = 0;
+       this_log_level = script_log_level;
+
+       while (ctdb->log->buf_used > 0 &&
+              (p = memchr(ctdb->log->buf, '\n', ctdb->log->buf_used)) != NULL) 
{
+               int n1 = (p - ctdb->log->buf)+1;
+               int n2 = n1 - 1;
+               /* swallow \r from child processes */
+               if (n2 > 0 && ctdb->log->buf[n2-1] == '\r') {
+                       n2--;
                }
-               return;
+               if (script_log_level <= LogLevel) {
+                       do_debug("%*.*s\n", n2, n2, ctdb->log->buf);
+               }
+               memmove(ctdb->log->buf, p+1, sizeof(ctdb->log->buf) - n1);
+               ctdb->log->buf_used -= n1;
        }
 
-       n1 = (p - ctdb->log->buf)+1;
-       n2 = n1 - 1;
-       /* swallow \r from child processes */
-       if (n2 > 0 && ctdb->log->buf[n2-1] == '\r') {
-               n2--;
+       /* the buffer could have completely filled - unfortunately we have
+          no choice but to dump it out straight away */
+       if (ctdb->log->buf_used == sizeof(ctdb->log->buf)) {
+               if (script_log_level <= LogLevel) {
+                       do_debug("%*.*s\n", 
+                               (int)ctdb->log->buf_used, 
(int)ctdb->log->buf_used, ctdb->log->buf);
+               }
+               ctdb->log->buf_used = 0;
        }
-       do_debug("%*.*s\n", n2, n2, ctdb->log->buf);
-       memmove(ctdb->log->buf, p+1, sizeof(ctdb->log->buf) - n1);
-       ctdb->log->buf_used -= n1;
 }
 
 
diff --git a/server/ctdbd.c b/server/ctdbd.c
index b797904..35e1cca 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -46,6 +46,7 @@ static struct {
        int         no_lmaster;
        int         no_recmaster;
        int         lvs;
+       int         script_log_level;
 } options = {
        .nlist = ETCDIR "/ctdb/nodes",
        .transport = "tcp",
@@ -53,8 +54,10 @@ static struct {
        .logfile = VARDIR "/log/log.ctdb",
        .db_dir = VARDIR "/ctdb",
        .db_dir_persistent = VARDIR "/ctdb/persistent",
+       .script_log_level = DEBUG_ERR,
 };
 
+int script_log_level;
 
 /*
   called by the transport layer when a packet comes in
@@ -126,6 +129,7 @@ int main(int argc, const char *argv[])
                { "no-lmaster", 0, POPT_ARG_NONE, &options.no_lmaster, 0, 
"disable lmaster role on this node", NULL },
                { "no-recmaster", 0, POPT_ARG_NONE, &options.no_recmaster, 0, 
"disable recmaster role on this node", NULL },
                { "lvs", 0, POPT_ARG_NONE, &options.lvs, 0, "lvs is enabled on 
this node", NULL },
+               { "script-log-level", 0, POPT_ARG_INT, 
&options.script_log_level, DEBUG_ERR, "log level of event script output", NULL 
},
                POPT_TABLEEND
        };
        int opt, ret;
@@ -167,6 +171,8 @@ int main(int argc, const char *argv[])
 
        ctdb->start_as_disabled = options.start_as_disabled;
 
+       script_log_level = options.script_log_level;
+
        ret = ctdb_set_logfile(ctdb, options.logfile, options.use_syslog);
        if (ret == -1) {
                printf("ctdb_set_logfile to %s failed - %s\n", 


-- 
CTDB repository

Reply via email to