ctdb-locking: Restrict lock debugging to once per second
authorAmitay Isaacs <amitay@gmail.com>
Thu, 22 Sep 2016 04:06:44 +0000 (14:06 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 22 Sep 2016 06:34:20 +0000 (08:34 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/server/ctdb_lock.c

index 46498e079ef95fffc9e9fdf3354bee1ee1d99732..3a58711bc4b3d576dbb4ac8b9f13660efc3a2630 100644 (file)
@@ -392,8 +392,10 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
                                    void *private_data)
 {
        static char debug_locks[PATH_MAX+1] = "";
+       static struct timeval last_debug_time;
        struct lock_context *lock_ctx;
        struct ctdb_context *ctdb;
+       struct timeval now;
        pid_t pid;
        double elapsed_time;
        int new_timer;
@@ -418,6 +420,14 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
                goto skip_lock_debug;
        }
 
+       /* Restrict log debugging to once per second */
+       now = timeval_current();
+       if (last_debug_time.tv_sec == now.tv_sec) {
+               goto skip_lock_debug;
+       }
+
+       last_debug_time.tv_sec = now.tv_sec;
+
        if (ctdb_set_helper("lock debugging helper",
                            debug_locks, sizeof(debug_locks),
                            "CTDB_DEBUG_LOCKS",