samba-cvs.cvs
[Top] [All Lists]

[SCM] CTDB repository - branch master updated - ctdb-1.0.105-62-gcc99c05

Subject: [SCM] CTDB repository - branch master updated - ctdb-1.0.105-62-gcc99c05
From: Ronnie Sahlberg
Date: Thu, 3 Dec 2009 18:48:04 -0600 CST
The branch, master has been updated
       via  cc99c05c0c6484ad574039a454e6133852cb41fa (commit)
       via  c5cbb95512f034abeec515579983bf7ac55eadd9 (commit)
      from  0a0526e03ef995b6b6634f5b75c7a17cb7b5df8f (commit)

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


- Log -----------------------------------------------------------------
commit cc99c05c0c6484ad574039a454e6133852cb41fa
Author: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
Date:   Fri Dec 4 11:45:37 2009 +1100

    Dont store debug level DEBUG_DEBUG in the in-memory ringbuffer.
    
    It is unlikely we will need something this verbose for normal 
troubleshooting.
    This allows us to keep a significantly longer time interval of log messages
    in the 500k slots available in the ringbuffer.

commit c5cbb95512f034abeec515579983bf7ac55eadd9
Author: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
Date:   Fri Dec 4 11:36:27 2009 +1100

    Use statically allocated ringbuffer to store the last 500k log entries
    in memory instead of dynamically allocated ones so that we reduce the 
pressure
    on malloc/free.

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

Summary of changes:
 common/ctdb_logging.c |   20 +++++++++-----------
 include/includes.h    |    2 +-
 lib/util/debug.c      |    2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index efb47c6..64507f4 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -24,15 +24,18 @@
 #include "../include/ctdb_private.h"
 #include "../include/ctdb.h"
 
+#define MAX_LOG_ENTRIES 500000
+#define MAX_LOG_SIZE 128
+
+static int first_entry;
+static int last_entry;
+
 struct ctdb_log_entry {
        int32_t level;
        struct timeval t;
-       char *message;
+       char message[MAX_LOG_SIZE];
 };
 
-#define MAX_LOG_ENTRIES 500000
-static int first_entry;
-static int last_entry;
 
 static struct ctdb_log_entry log_entries[MAX_LOG_ENTRIES];
 
@@ -42,21 +45,16 @@ static struct ctdb_log_entry log_entries[MAX_LOG_ENTRIES];
 static void log_ringbuffer_v(const char *format, va_list ap)
 {
        int ret;
-       char *s = NULL;
 
-       if (log_entries[last_entry].message != NULL) {
-               free(log_entries[last_entry].message);
-               log_entries[last_entry].message = NULL;
-       }
+       log_entries[last_entry].message[0] = '\0';
 
-       ret = vasprintf(&s, format, ap);
+       ret = vsnprintf(&log_entries[last_entry].message[0], MAX_LOG_SIZE, 
format, ap);
        if (ret == -1) {
                return;
        }
 
        log_entries[last_entry].level = this_log_level;
        log_entries[last_entry].t = timeval_current();
-       log_entries[last_entry].message = s;
 
        last_entry++;
        if (last_entry >= MAX_LOG_ENTRIES) {
diff --git a/include/includes.h b/include/includes.h
index 4b4d242..b7e2105 100644
--- a/include/includes.h
+++ b/include/includes.h
@@ -28,7 +28,7 @@ enum debug_level {
        DEBUG_DEBUG   =  4,
 };
 
-#define DEBUG(lvl, x) do { this_log_level = (lvl); log_ringbuffer x; if ((lvl) 
<= LogLevel) { do_debug x; }} while (0)
+#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) < DEBUG_DEBUG) { 
log_ringbuffer x; } if ((lvl) <= LogLevel) { do_debug x; }} while (0)
 
 #define _PUBLIC_
 
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 6597570..d4d3bd6 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -90,7 +90,7 @@ void do_debug_add(const char *format, ...)
 }
 
 #define DEBUGLVL(lvl) ((lvl) <= LogLevel)
-#define DEBUG(lvl, x) do { this_log_level = (lvl); log_ringbuffer x; if ((lvl) 
<= LogLevel) { do_debug x; }} while (0)
+#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) < DEBUG_DEBUG) { 
log_ringbuffer x; } if ((lvl) <= LogLevel) { do_debug x; }} while (0)
 #define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); 
do_debug_add x; }} while (0)
 
 static void print_asc(int level, const uint8_t *buf, size_t len)


-- 
CTDB repository

<Prev in Thread] Current Thread [Next in Thread>
  • [SCM] CTDB repository - branch master updated - ctdb-1.0.105-62-gcc99c05, Ronnie Sahlberg <=