r23563: Add dump-event-list command to smbcontrol.
[sfrench/samba-autobuild/.git] / source / utils / smbcontrol.c
index 637cdacffa433f92b733e52a8d2c8a52754fa748..83ccce7057f7d6e9c63b232c5cba54de107a1ef5 100644 (file)
@@ -49,8 +49,7 @@ static int num_replies;               /* Used by message callback fns */
 
 static BOOL send_message(struct messaging_context *msg_ctx,
                         struct server_id pid, int msg_type,
-                        const void *buf, int len,
-                        BOOL duplicates)
+                        const void *buf, int len)
 {
        BOOL ret;
        int n_sent = 0;
@@ -60,8 +59,7 @@ static BOOL send_message(struct messaging_context *msg_ctx,
                        messaging_send_buf(msg_ctx, pid, msg_type,
                                           (uint8 *)buf, len));
 
-       ret = message_send_all(msg_ctx, msg_type, buf, len, duplicates,
-                              &n_sent);
+       ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
        DEBUG(10,("smbcontrol/send_message: broadcast message to "
                  "%d processes\n", n_sent));
        
@@ -79,7 +77,7 @@ static void wait_replies(struct messaging_context *msg_ctx,
            busy-wait here as there is no nicer way to do it. */
 
        do {
-               message_dispatch();
+               message_dispatch(msg_ctx);
                event_loop_once(messaging_event_context(msg_ctx));
                if (num_replies > 0 && !multiple_replies)
                        break;
@@ -140,8 +138,8 @@ static BOOL do_debug(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False);
+       return send_message(msg_ctx, pid, MSG_DEBUG, argv[1],
+                           strlen(argv[1]) + 1);
 }
 
 #if defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE)
@@ -245,9 +243,10 @@ cleanup:
        ptrace(PTRACE_DETACH, pid, NULL, NULL);
 }
 
-static int stack_trace_connection(TDB_CONTEXT * tdb, 
+static int stack_trace_connection(struct db_record *rec,
                                  const struct connections_key *key,
-                                 const struct connections_data *conn,
+                                 const struct connections_data *crec,
+                                 void *priv)
 {
        print_stack_trace(procid_to_pid(&conn->pid), (int *)priv);
 
@@ -280,7 +279,7 @@ static BOOL do_daemon_stack_trace(struct messaging_context *msg_ctx,
                 */
                print_stack_trace(dest, &count);
        } else {
-               connections_traverse(stack_trace_connection, &count);
+               connections_forall(stack_trace_connection, &count);
        }
 
        return True;
@@ -336,7 +335,7 @@ static BOOL do_inject_fault(struct messaging_context *msg_ctx,
                }
 
                return send_message(msg_ctx, pid, MSG_SMB_INJECT_FAULT,
-                                   &sig, sizeof(int), False);
+                                   &sig, sizeof(int));
        }
 #endif /* DEVELOPER */
 }
@@ -352,8 +351,7 @@ static BOOL do_election(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_FORCE_ELECTION, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_FORCE_ELECTION, NULL, 0);
 }
 
 /* Ping a samba daemon process */
@@ -381,7 +379,7 @@ static BOOL do_ping(struct messaging_context *msg_ctx,
 
        /* Send a message and register our interest in a reply */
 
-       if (!send_message(msg_ctx, pid, MSG_PING, NULL, 0, False))
+       if (!send_message(msg_ctx, pid, MSG_PING, NULL, 0))
                return False;
 
        messaging_register(msg_ctx, NULL, MSG_PONG, pong_cb);
@@ -425,7 +423,7 @@ static BOOL do_profile(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx, pid, MSG_PROFILE, &v, sizeof(int), False);
+       return send_message(msg_ctx, pid, MSG_PROFILE, &v, sizeof(int));
 }
 
 /* Return the profiling level */
@@ -480,7 +478,7 @@ static void profilelevel_rqst(struct messaging_context *msg_ctx,
 
        /* Send back a dummy reply */
 
-       send_message(msg_ctx, pid, MSG_PROFILELEVEL, &v, sizeof(int), False);
+       send_message(msg_ctx, pid, MSG_PROFILELEVEL, &v, sizeof(int));
 }
 
 static BOOL do_profilelevel(struct messaging_context *msg_ctx,
@@ -494,7 +492,7 @@ static BOOL do_profilelevel(struct messaging_context *msg_ctx,
 
        /* Send a message and register our interest in a reply */
 
-       if (!send_message(msg_ctx, pid, MSG_REQ_PROFILELEVEL, NULL, 0, False))
+       if (!send_message(msg_ctx, pid, MSG_REQ_PROFILELEVEL, NULL, 0))
                return False;
 
        messaging_register(msg_ctx, NULL, MSG_PROFILELEVEL, profilelevel_cb);
@@ -526,7 +524,7 @@ static BOOL do_debuglevel(struct messaging_context *msg_ctx,
 
        /* Send a message and register our interest in a reply */
 
-       if (!send_message(msg_ctx, pid, MSG_REQ_DEBUGLEVEL, NULL, 0, False))
+       if (!send_message(msg_ctx, pid, MSG_REQ_DEBUGLEVEL, NULL, 0))
                return False;
 
        messaging_register(msg_ctx, NULL, MSG_DEBUGLEVEL, print_pid_string_cb);
@@ -696,8 +694,36 @@ static BOOL do_closeshare(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_SMB_FORCE_TDIS, argv[1], strlen(argv[1]) + 1, False);
+       return send_message(msg_ctx, pid, MSG_SMB_FORCE_TDIS, argv[1],
+                           strlen(argv[1]) + 1);
+}
+
+/* force a blocking lock retry */
+
+static BOOL do_lockretry(struct messaging_context *msg_ctx,
+                        const struct server_id pid,
+                        const int argc, const char **argv)
+{
+       if (argc != 1) {
+               fprintf(stderr, "Usage: smbcontrol <dest> lockretry\n");
+               return False;
+       }
+
+       return send_message(msg_ctx, pid, MSG_SMB_UNLOCK, NULL, 0);
+}
+
+/* force a validation of all brl entries, including re-sends. */
+
+static BOOL do_brl_revalidate(struct messaging_context *msg_ctx,
+                             const struct server_id pid,
+                             const int argc, const char **argv)
+{
+       if (argc != 1) {
+               fprintf(stderr, "Usage: smbcontrol <dest> brl-revalidate\n");
+               return False;
+       }
+
+       return send_message(msg_ctx, pid, MSG_SMB_BRL_VALIDATE, NULL, 0);
 }
 
 /* Force a SAM synchronisation */
@@ -711,8 +737,7 @@ static BOOL do_samsync(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_SMB_SAM_SYNC, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_SMB_SAM_SYNC, NULL, 0);
 }
 
 /* Force a SAM replication */
@@ -726,8 +751,7 @@ static BOOL do_samrepl(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_SMB_SAM_REPL, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_SMB_SAM_REPL, NULL, 0);
 }
 
 /* Display talloc pool usage */
@@ -745,7 +769,7 @@ static BOOL do_poolusage(struct messaging_context *msg_ctx,
 
        /* Send a message and register our interest in a reply */
 
-       if (!send_message(msg_ctx, pid, MSG_REQ_POOL_USAGE, NULL, 0, False))
+       if (!send_message(msg_ctx, pid, MSG_REQ_POOL_USAGE, NULL, 0))
                return False;
 
        wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
@@ -771,8 +795,7 @@ static BOOL do_dmalloc_mark(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_REQ_DMALLOC_MARK, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_REQ_DMALLOC_MARK, NULL, 0);
 }
 
 /* Perform a dmalloc changed */
@@ -787,8 +810,8 @@ static BOOL do_dmalloc_changed(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_REQ_DMALLOC_LOG_CHANGED, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_REQ_DMALLOC_LOG_CHANGED,
+                           NULL, 0);
 }
 
 /* Shutdown a server process */
@@ -802,7 +825,7 @@ static BOOL do_shutdown(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx, pid, MSG_SHUTDOWN, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_SHUTDOWN, NULL, 0);
 }
 
 /* Notify a driver upgrade */
@@ -817,8 +840,8 @@ static BOOL do_drvupgrade(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx,
-               pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False);
+       return send_message(msg_ctx, pid, MSG_DEBUG, argv[1],
+                           strlen(argv[1]) + 1);
 }
 
 static BOOL do_winbind_online(struct messaging_context *msg_ctx,
@@ -852,7 +875,7 @@ static BOOL do_winbind_online(struct messaging_context *msg_ctx,
        tdb_delete_bystring(tdb, "WINBINDD_OFFLINE");
        tdb_close(tdb);
 
-       return send_message(msg_ctx, pid, MSG_WINBIND_ONLINE, NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_WINBIND_ONLINE, NULL, 0);
 }
 
 static BOOL do_winbind_offline(struct messaging_context *msg_ctx,
@@ -909,7 +932,7 @@ static BOOL do_winbind_offline(struct messaging_context *msg_ctx,
                tdb_store_bystring(tdb, "WINBINDD_OFFLINE", d, TDB_INSERT);
 
                ret = send_message(msg_ctx, pid, MSG_WINBIND_OFFLINE,
-                                  NULL, 0, False);
+                                  NULL, 0);
 
                /* Check that the entry "WINBINDD_OFFLINE" still exists. */
                d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" );
@@ -944,7 +967,7 @@ static BOOL do_winbind_onlinestatus(struct messaging_context *msg_ctx,
                           print_pid_string_cb);
 
        if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, &myid,
-                         sizeof(myid), False))
+                         sizeof(myid)))
                return False;
 
        wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
@@ -959,6 +982,22 @@ static BOOL do_winbind_onlinestatus(struct messaging_context *msg_ctx,
        return num_replies;
 }
 
+static BOOL do_dump_event_list(struct messaging_context *msg_ctx,
+                              const struct server_id pid,
+                              const int argc, const char **argv)
+{
+       struct server_id myid;
+
+       myid = pid_to_procid(sys_getpid());
+
+       if (argc != 1) {
+               fprintf(stderr, "Usage: smbcontrol <dest> dump-event-list\n");
+               return False;
+       }
+
+       return send_message(msg_ctx, pid, MSG_DUMP_EVENT_LIST, NULL, 0);
+}
+
 
 static BOOL do_reload_config(struct messaging_context *msg_ctx,
                             const struct server_id pid,
@@ -969,8 +1008,7 @@ static BOOL do_reload_config(struct messaging_context *msg_ctx,
                return False;
        }
 
-       return send_message(msg_ctx, pid, MSG_SMB_CONF_UPDATED,
-                           NULL, 0, False);
+       return send_message(msg_ctx, pid, MSG_SMB_CONF_UPDATED, NULL, 0);
 }
 
 static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
@@ -1018,8 +1056,7 @@ static BOOL do_nodestatus(struct messaging_context *msg_ctx,
        p.packet.nmb.question.question_type = 0x21;
        p.packet.nmb.question.question_class = 0x1;
 
-       return send_message(msg_ctx, pid, MSG_SEND_PACKET, &p, sizeof(p),
-                           False);
+       return send_message(msg_ctx, pid, MSG_SEND_PACKET, &p, sizeof(p));
 }
 
 /* A list of message type supported */
@@ -1044,6 +1081,8 @@ static const struct {
        { "debuglevel", do_debuglevel, "Display current debuglevels" },
        { "printnotify", do_printnotify, "Send a print notify message" },
        { "close-share", do_closeshare, "Forcibly disconnect a share" },
+       { "lockretry", do_lockretry, "Force a blocking lock retry" },
+       { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" },
         { "samsync", do_samsync, "Initiate SAM synchronisation" },
         { "samrepl", do_samrepl, "Initiate SAM replication" },
        { "pool-usage", do_poolusage, "Display talloc memory usage" },
@@ -1056,6 +1095,7 @@ static const struct {
        { "online", do_winbind_online, "Ask winbind to go into online state"},
        { "offline", do_winbind_offline, "Ask winbind to go into offline state"},
        { "onlinestatus", do_winbind_onlinestatus, "Request winbind online status"},
+       { "dump-event-list", do_dump_event_list, "Dump event list"},
        { "noop", do_noop, "Do nothing" },
        { NULL }
 };