[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Mon Nov 16 07:41:47 UTC 2015


The branch, master has been updated
       via  6b4a961 ctdb-build: Remove ctdb-common-util subsystem
       via  0fffdc1 ctdb-daemon: Remove unused ctdb_logging.[ch]
       via  27bc80c ctdb-tool: Use new debug level API
       via  9c16aec ctdb-common: Use new debug level API
       via  8b1bf86 ctdb-tests: Build in common/logging.c
       via  1757755 ctdb-tests: Replace ctdb_logging.h with common/logging.h
       via  921d815 ctdb-transport: Replace ctdb_logging.h with common/logging.h
       via  f50db5c ctdb-server: Replace ctdb_logging.h with common/logging.h
       via  3f31415 ctdb-common: Replace ctdb_logging.h with common/logging.h
       via  7258e1d ctdb-client: Replace ctdb_logging.h with common/logging.h
       via  145da0b ctdb-system: Replace ctdb_logging.h with common/logging.h
       via  7e376f0 ctdb-logging: Remove duplicate definitions
       via  dd7d2a4 ctdb-tests: Update test to set numeric debug levels
       via  3d8c1ca ctdb-logging: Allow numeric specification of debug level
       via  2ddc527 ctdb-logging: Allow sub-string matching for debug level strings
       via  64ef27b ctdb-logging: Fix for loop condition
       via  8534408 ctdb-logging: Add APIs to convert debug_level to and from integer
       via  c170cdb ctdb-logging: Move debug_extra definition to server/ctdb_logging.c
       via  7dd2f1c ctdb-daemon: Move ctdb_fork.c to server
       via  848da80 ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
      from  eee4af5 WHATSNEW: Add async SMB2 flush and new aio parameter

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6b4a961d02aeb4e7d5b8eea0b5323919a9ed64fb
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:52:30 2015 +1100

    ctdb-build: Remove ctdb-common-util subsystem
    
    Include system_util.c in ctdb-system subsystem.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Mon Nov 16 03:51:36 CET 2015 on sn-devel-104

commit 0fffdc1901a7773d60111ad74aadec34741403e1
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:43:44 2015 +1100

    ctdb-daemon: Remove unused ctdb_logging.[ch]
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 27bc80cf6a6b3a3c27b5b4553bfb529bd83a1da2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:40:41 2015 +1100

    ctdb-tool: Use new debug level API
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 9c16aec72f0f371a7aa76147f6ab202006326ff0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:19:41 2015 +1100

    ctdb-common: Use new debug level API
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 8b1bf86dc52f7f5812cba7e49dc3dbc5defb5ba6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:33:43 2015 +1100

    ctdb-tests: Build in common/logging.c
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 17577550d803eb6313d1a8f43a854b0cce523466
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:00:23 2015 +1100

    ctdb-tests: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 921d815da0f0e3a3520cf1bef082188d09fae1b9
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:22:52 2015 +1100

    ctdb-transport: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit f50db5cba526182dafe73ddf7cebc21357ddcb2e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:41:10 2015 +1100

    ctdb-server: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3f314154fe0474cfe716e1d8e66e87ecf2404fe4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:19:17 2015 +1100

    ctdb-common: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 7258e1d9c9815e62129a34acf4bedfe54743ea18
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:17:56 2015 +1100

    ctdb-client: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 145da0b68fb668f53d79f3aa302120b26f2e5ba6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 14:43:56 2015 +1100

    ctdb-system: Replace ctdb_logging.h with common/logging.h
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 7e376f0dbc2047f44060c81aff8de059160a0f4e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 15:10:38 2015 +1100

    ctdb-logging: Remove duplicate definitions
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit dd7d2a400e59e661c217d4fa6f93d814651dabc8
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 13 12:03:43 2015 +1100

    ctdb-tests: Update test to set numeric debug levels
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3d8c1ca80aab82823b7cf9360cdc742e80a86e8f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Nov 12 09:15:08 2015 +1100

    ctdb-logging: Allow numeric specification of debug level
    
    This makes the function compatible with parse_debug().
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 2ddc5274ba9d171d4693d994168eb7072c911568
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 16:17:51 2015 +1100

    ctdb-logging: Allow sub-string matching for debug level strings
    
    This allows for backward compatibility with the current code where
    DEBUG_ERR corresponds to "ERR".
    
    Fix the test that relies on "ERR" instead of "ERROR".
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 64ef27b27f7d343707d30902c70ae63540547d69
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Nov 12 09:14:32 2015 +1100

    ctdb-logging: Fix for loop condition
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 8534408e03a11f96b681601c886eccd0d60d6b60
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 14:45:08 2015 +1100

    ctdb-logging: Add APIs to convert debug_level to and from integer
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit c170cdbc75c86af6b4c566966b60f172d677c8a6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 14:31:41 2015 +1100

    ctdb-logging: Move debug_extra definition to server/ctdb_logging.c
    
    This variable is used for adding a prefix to log entries from various
    child processes.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 7dd2f1c35a916ae5eff8f1bf77b6f7feff802b81
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 14:26:53 2015 +1100

    ctdb-daemon: Move ctdb_fork.c to server
    
    These functions are only used in the ctdb daemon code.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 848da801527828979751c0c42b701bd99ff674e1
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Nov 11 14:18:51 2015 +1100

    ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
    
    This function can only called from ctdb daemon.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 ctdb/client/client_connect.c          |  2 +-
 ctdb/client/client_control_sync.c     |  3 +-
 ctdb/client/client_db.c               |  3 +-
 ctdb/client/client_message_sync.c     |  3 +-
 ctdb/client/client_util.c             |  3 +-
 ctdb/client/ctdb_client.c             | 34 +-------------
 ctdb/common/cmdline.c                 | 16 ++++---
 ctdb/common/common.h                  | 12 -----
 ctdb/common/ctdb_io.c                 |  2 +-
 ctdb/common/ctdb_logging.c            | 85 -----------------------------------
 ctdb/common/ctdb_ltdb.c               |  2 +-
 ctdb/common/ctdb_util.c               |  2 +-
 ctdb/common/logging.c                 | 35 +++++++++++++--
 ctdb/common/logging.h                 |  2 +
 ctdb/common/rb_tree.c                 |  4 +-
 ctdb/common/system_aix.c              |  2 +-
 ctdb/common/system_common.c           |  2 +-
 ctdb/common/system_freebsd.c          |  2 +-
 ctdb/common/system_gnu.c              |  2 +-
 ctdb/common/system_kfreebsd.c         |  2 +-
 ctdb/common/system_linux.c            |  2 +-
 ctdb/common/system_util.c             |  2 +-
 ctdb/ib/ibw_ctdb.c                    |  2 +-
 ctdb/ib/ibw_ctdb_init.c               |  2 +-
 ctdb/ib/ibwrapper.c                   |  2 +-
 ctdb/ib/ibwrapper_test.c              |  2 +-
 ctdb/include/ctdb_client.h            |  3 --
 ctdb/include/ctdb_logging.h           | 46 -------------------
 ctdb/include/ctdb_private.h           | 17 +++++++
 ctdb/server/ctdb_banning.c            |  2 +-
 ctdb/server/ctdb_call.c               |  2 +-
 ctdb/server/ctdb_control.c            |  2 +-
 ctdb/server/ctdb_daemon.c             | 34 +++++++++++++-
 ctdb/{common => server}/ctdb_fork.c   |  2 +-
 ctdb/server/ctdb_freeze.c             |  2 +-
 ctdb/server/ctdb_keepalive.c          |  2 +-
 ctdb/server/ctdb_lock.c               |  2 +-
 ctdb/server/ctdb_logging.c            |  4 +-
 ctdb/server/ctdb_logging_file.c       |  1 -
 ctdb/server/ctdb_logging_syslog.c     |  3 +-
 ctdb/server/ctdb_ltdb_server.c        |  2 +-
 ctdb/server/ctdb_monitor.c            |  2 +-
 ctdb/server/ctdb_persistent.c         |  2 +-
 ctdb/server/ctdb_recover.c            |  2 +-
 ctdb/server/ctdb_recoverd.c           |  2 +-
 ctdb/server/ctdb_server.c             |  2 +-
 ctdb/server/ctdb_serverids.c          |  2 +-
 ctdb/server/ctdb_statistics.c         |  3 +-
 ctdb/server/ctdb_takeover.c           |  2 +-
 ctdb/server/ctdb_traverse.c           |  2 +-
 ctdb/server/ctdb_tunables.c           |  2 +-
 ctdb/server/ctdb_update_record.c      |  2 +-
 ctdb/server/ctdb_uptime.c             |  2 +-
 ctdb/server/ctdb_vacuum.c             |  2 +-
 ctdb/server/ctdbd.c                   |  2 +-
 ctdb/server/eventscript.c             |  2 +-
 ctdb/tcp/tcp_connect.c                |  2 +-
 ctdb/tcp/tcp_init.c                   |  2 +-
 ctdb/tcp/tcp_io.c                     |  2 +-
 ctdb/tests/simple/13_ctdb_setdebug.sh | 16 +++++--
 ctdb/tests/src/ctdb_bench.c           |  2 +-
 ctdb/tests/src/ctdb_persistent.c      |  2 +-
 ctdb/tests/src/ctdb_porting_tests.c   |  2 +-
 ctdb/tests/src/ctdb_randrec.c         |  2 +-
 ctdb/tests/src/ctdb_test.c            |  4 +-
 ctdb/tests/src/ctdb_transaction.c     |  2 +-
 ctdb/tests/src/ctdbd_test.c           |  5 +--
 ctdb/tools/ctdb.c                     | 14 +++---
 ctdb/wscript                          | 33 +++++---------
 69 files changed, 195 insertions(+), 278 deletions(-)
 delete mode 100644 ctdb/common/ctdb_logging.c
 delete mode 100644 ctdb/include/ctdb_logging.h
 rename ctdb/{common => server}/ctdb_fork.c (99%)


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client_connect.c b/ctdb/client/client_connect.c
index 5f2b62e..0c92485 100644
--- a/ctdb/client/client_connect.c
+++ b/ctdb/client/client_connect.c
@@ -28,10 +28,10 @@
 #include "common/reqid.h"
 #include "common/srvid.h"
 #include "common/comm.h"
+#include "common/logging.h"
 
 #include "lib/util/tevent_unix.h"
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_api.h"
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index 3f5ffb8..de52b47 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -25,8 +25,9 @@
 #include <tevent.h>
 #include <tdb.h>
 
+#include "common/logging.h"
+
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_api.h"
diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c
index 146c5e1..6af607a 100644
--- a/ctdb/client/client_db.c
+++ b/ctdb/client/client_db.c
@@ -25,11 +25,12 @@
 #include <tevent.h>
 #include <tdb.h>
 
+#include "common/logging.h"
+
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/util/tevent_unix.h"
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_api.h"
diff --git a/ctdb/client/client_message_sync.c b/ctdb/client/client_message_sync.c
index b6e53f3..4bcc122 100644
--- a/ctdb/client/client_message_sync.c
+++ b/ctdb/client/client_message_sync.c
@@ -25,8 +25,9 @@
 #include <tevent.h>
 #include <tdb.h>
 
+#include "common/logging.h"
+
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_api.h"
diff --git a/ctdb/client/client_util.c b/ctdb/client/client_util.c
index bb2dd6e..c4dbe04 100644
--- a/ctdb/client/client_util.c
+++ b/ctdb/client/client_util.c
@@ -25,8 +25,9 @@
 #include <tevent.h>
 #include <tdb.h>
 
+#include "common/logging.h"
+
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_api.h"
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index c655ffd..b9f9cf9 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -35,13 +35,13 @@
 #include "lib/util/debug.h"
 #include "lib/util/samba_util.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
 
 #include "common/reqid.h"
 #include "common/system.h"
 #include "common/common.h"
+#include "common/logging.h"
 
 /*
   allocate a packet for use in client<->daemon communication
@@ -4388,38 +4388,6 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb)
 	return 0;
 }
 
-/* When forking the main daemon and the child process needs to connect
- * back to the daemon as a client process, this function can be used
- * to change the ctdb context from daemon into client mode.  The child
- * process must be created using ctdb_fork() and not fork() -
- * ctdb_fork() does some necessary housekeeping.
- */
-int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	/* Add extra information so we can identify this in the logs */
-	va_start(ap, fmt);
-	debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
-	va_end(ap);
-
-	/* get a new event context */
-	ctdb->ev = tevent_context_init(ctdb);
-	tevent_loop_allow_nesting(ctdb->ev);
-
-	/* Connect to main CTDB daemon */
-	ret = ctdb_socket_connect(ctdb);
-	if (ret != 0) {
-		DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
-		return -1;
-	}
-
-	ctdb->can_send_controls = true;
-
-	return 0;
-}
-
 /*
   get the status of running the monitor eventscripts: NULL means never run.
  */
diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c
index 69e8231..02083e8 100644
--- a/ctdb/common/cmdline.c
+++ b/ctdb/common/cmdline.c
@@ -27,12 +27,12 @@
 #include <ctype.h>
 
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
 
 #include "common/rb_tree.h"
 #include "common/common.h"
+#include "common/logging.h"
 #include "common/cmdline.h"
 
 
@@ -81,6 +81,7 @@ struct poptOption popt_ctdb_cmdline[] = {
 struct ctdb_context *ctdb_cmdline_init(struct tevent_context *ev)
 {
 	struct ctdb_context *ctdb;
+	enum debug_level log_level;
 	int ret;
 
 	/* initialise ctdb */
@@ -106,8 +107,10 @@ struct ctdb_context *ctdb_cmdline_init(struct tevent_context *ev)
 	}
 
 	/* Set the debug level */
-	if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
-		DEBUGLEVEL = DEBUG_NOTICE;
+	if (debug_level_parse(ctdb_cmdline.debuglevel, &log_level)) {
+		DEBUGLEVEL = debug_level_to_int(log_level);
+	} else {
+		DEBUGLEVEL = debug_level_to_int(DEBUG_NOTICE);
 	}
 
 	/* set up the tree to store server ids */
@@ -124,6 +127,7 @@ struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
 					 struct timeval req_timeout)
 {
 	struct ctdb_context *ctdb;
+	enum debug_level log_level;
 	char *socket_name;
 	int ret;
 
@@ -155,8 +159,10 @@ struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
 	}
 
 	/* Set the debug level */
-	if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
-		DEBUGLEVEL = DEBUG_NOTICE;
+	if (debug_level_parse(ctdb_cmdline.debuglevel, &log_level)) {
+		DEBUGLEVEL = debug_level_to_int(log_level);
+	} else {
+		DEBUGLEVEL = debug_level_to_int(DEBUG_NOTICE);
 	}
 
 	ret = ctdb_socket_connect(ctdb);
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index 1cf8a7d..b89a84c 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -20,18 +20,6 @@
 #ifndef __CTDB_COMMON_H__
 #define __CTDB_COMMON_H__
 
-/* From common/ctdb_fork.c */
-
-void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);
-
-void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
-
-pid_t ctdb_fork(struct ctdb_context *ctdb);
-
-struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
-
-int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum);
-
 /* From common/ctdb_io.c */
 
 int ctdb_queue_length(struct ctdb_queue *queue);
diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c
index 632574e..24968b3 100644
--- a/ctdb/common/ctdb_io.c
+++ b/ctdb/common/ctdb_io.c
@@ -31,11 +31,11 @@
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
 
 #include "common/system.h"
+#include "common/logging.h"
 #include "common/common.h"
 
 #define QUEUE_BUFFER_SIZE	(16*1024)
diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c
deleted file mode 100644
index e76966c..0000000
--- a/ctdb/common/ctdb_logging.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* 
-   ctdb logging code
-
-   Copyright (C) Ronnie Sahlberg 2009
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <ctype.h>
-#include "replace.h"
-#include "ctdb_logging.h"
-
-const char *debug_extra = "";
-
-struct debug_levels {
-	int32_t	level;
-	const char *description;
-};
-
-static struct debug_levels debug_levels[] = {
-	{DEBUG_ERR,	"ERR"},
-	{DEBUG_WARNING,	"WARNING"},
-	{DEBUG_NOTICE,	"NOTICE"},
-	{DEBUG_INFO,	"INFO"},
-	{DEBUG_DEBUG,	"DEBUG"},
-	{0, NULL}
-};
-
-const char *get_debug_by_level(int32_t level)
-{
-	int i;
-
-	for (i=0; debug_levels[i].description != NULL; i++) {
-		if (debug_levels[i].level == level) {
-			return debug_levels[i].description;
-		}
-	}
-	return NULL;
-}
-
-static bool get_debug_by_desc(const char *desc, int32_t *level)
-{
-	int i;
-
-	for (i=0; debug_levels[i].description != NULL; i++) {
-		if (!strcasecmp(debug_levels[i].description, desc)) {
-			*level = debug_levels[i].level;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-bool parse_debug(const char *str, int32_t *level)
-{
-	if (isalpha(str[0])) {
-		return get_debug_by_desc(str, level);
-	} else {
-		*level = strtol(str, NULL, 0);
-		return get_debug_by_level(*level) != NULL;
-	}
-}
-
-void print_debug_levels(FILE *stream)
-{
-	int i;
-
-	for (i=0; debug_levels[i].description != NULL; i++) {
-		fprintf(stream,
-			"%s (%d)\n",
-			debug_levels[i].description, debug_levels[i].level);
-	}
-}
diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c
index 39775be..6c941d8 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -28,10 +28,10 @@
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 
 #include "common/common.h"
+#include "common/logging.h"
 
 /*
   find an attached ctdb_db handle given a name
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 209735c..39108bc 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -27,12 +27,12 @@
 #include "lib/util/debug.h"
 #include "lib/util/samba_util.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 
 #include "common/reqid.h"
 #include "common/system.h"
 #include "common/common.h"
+#include "common/logging.h"
 
 /*
   return error string for last error
diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index 82cf3d9..f230471 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -18,6 +18,7 @@
 */
 
 #include <replace.h>
+#include <system/locale.h>
 
 #include "common/logging.h"
 
@@ -36,9 +37,19 @@ bool debug_level_parse(const char *log_string, enum debug_level *log_level)
 {
 	int i;
 
-	for (i=0; ARRAY_SIZE(log_string_map); i++) {
-		if (strcasecmp(log_string_map[i].log_string,
-			       log_string) == 0) {
+	if (isdigit(log_string[0])) {
+		int level = atoi(log_string);
+
+		if (level >= 0 && level < ARRAY_SIZE(log_string_map)) {
+			*log_level = debug_level_from_int(level);
+			return true;
+		}
+		return false;
+	}
+
+	for (i=0; i<ARRAY_SIZE(log_string_map); i++) {
+		if (strncasecmp(log_string_map[i].log_string,
+				log_string, strlen(log_string)) == 0) {
 			*log_level = log_string_map[i].log_level;
 			return true;
 		}
@@ -72,3 +83,21 @@ enum debug_level debug_level_from_string(const char *log_string)
 	/* Default debug level */
 	return DEBUG_ERR;
 }
+
+int debug_level_to_int(enum debug_level log_level)
+{
+	return (int)log_level;
+}
+
+enum debug_level debug_level_from_int(int level)
+{
+	enum debug_level log_level;
+
+	if (level >= 0 && level < ARRAY_SIZE(log_string_map)) {
+		log_level = log_string_map[level].log_level;
+	} else {
+		log_level = DEBUG_ERR;
+	}
+
+	return log_level;
+}
diff --git a/ctdb/common/logging.h b/ctdb/common/logging.h
index f427fbb..64b835c 100644
--- a/ctdb/common/logging.h
+++ b/ctdb/common/logging.h
@@ -35,5 +35,7 @@ enum debug_level {
 bool debug_level_parse(const char *log_string, enum debug_level *log_level);
 const char *debug_level_to_string(enum debug_level log_level);
 enum debug_level debug_level_from_string(const char *log_string);
+int debug_level_to_int(enum debug_level log_level);
+enum debug_level debug_level_from_int(int log_int);
 
 #endif /* __CTDB_LOGGING_H__ */
diff --git a/ctdb/common/rb_tree.c b/ctdb/common/rb_tree.c
index 6b0982f..1c602a7 100644
--- a/ctdb/common/rb_tree.c
+++ b/ctdb/common/rb_tree.c
@@ -22,9 +22,9 @@
 #include <talloc.h>
 
 #include "lib/util/debug.h"
-#include "ctdb_logging.h"
 
-#include "rb_tree.h"
+#include "common/logging.h"
+#include "common/rb_tree.h"
 
 #define NO_MEMORY_FATAL(p) do { if (!(p)) { \
           DEBUG(DEBUG_CRIT,("Out of memory for %s at %s\n", #p, __location__)); \
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 141e891..4c13106 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -26,7 +26,6 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 
 #include <netinet/if_ether.h>
@@ -36,6 +35,7 @@
 #include <sys/kinfo.h>
 #include <pcap.h>
 
+#include "common/logging.h"
 #include "common/system.h"
 
 
diff --git a/ctdb/common/system_common.c b/ctdb/common/system_common.c
index 9b12236..9c8e983 100644
--- a/ctdb/common/system_common.c
+++ b/ctdb/common/system_common.c
@@ -23,9 +23,9 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 
+#include "common/logging.h"
 #include "common/system.h"
 
 /*
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index b8f3fbe..97ac06c 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -31,7 +31,6 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_private.h"
 
 #include <net/ethernet.h>
@@ -39,6 +38,7 @@
 #include <net/if_arp.h>
 #include <pcap.h>
 
+#include "common/logging.h"
 #include "common/system.h"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list