Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
ctdb-daemon: Log a message when vfork() takes long time
Browse files Browse the repository at this point in the history
Signed-off-by: Amitay Isaacs <[email protected]>
Reviewed-by: Martin Schwenke <[email protected]>

Autobuild-User(master): Martin Schwenke <[email protected]>
Autobuild-Date(master): Mon Sep 19 12:18:15 CEST 2016 on sn-devel-144
  • Loading branch information
amitay authored and Martin Schwenke committed Sep 19, 2016
1 parent 0617196 commit 28fad1c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ctdb/server/ctdb_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/blocking.h"
#include "lib/util/time.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
Expand Down Expand Up @@ -200,6 +201,8 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
struct tevent_fd *fde;
char **argv;
int i;
struct timeval before;
double delta_t;

log = talloc_zero(mem_ctx, struct ctdb_log_state);
CTDB_NO_MEMORY_NULL(ctdb, log);
Expand Down Expand Up @@ -230,6 +233,8 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
argv[i+2] = discard_const(helper_argv[i]);
}

before = timeval_current();

*pid = vfork();
if (*pid == 0) {
execv(helper, argv);
Expand All @@ -243,6 +248,11 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
goto free_log;
}

delta_t = timeval_elapsed(&before);
if (delta_t > 3.0) {
DEBUG(DEBUG_WARNING, ("vfork() took %lf seconds\n", delta_t));
}

ctdb_track_child(ctdb, *pid);

log->pfd = p[0];
Expand Down

0 comments on commit 28fad1c

Please sign in to comment.