*/
#include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
#include "system/filesys.h"
#include "system/wait.h"
#include "db_wrap.h"
static int childwrite_destructor(struct childwrite_handle *h)
{
- h->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_DECREMENT_STAT(h->ctdb, pending_childwrite_calls);
kill(h->child, SIGKILL);
return 0;
}
int ret;
char c;
- ctdb_latency(h->ctdb_db, "persistent", &h->ctdb->statistics.max_childwrite_latency, h->start_time);
- h->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "persistent", childwrite_latency, h->start_time);
+ CTDB_DECREMENT_STAT(h->ctdb, pending_childwrite_calls);
/* the handle needs to go away when the context is gone - when
the handle goes away this implicitly closes the pipe, which
int ret;
pid_t parent = getpid();
- ctdb_db->ctdb->statistics.childwrite_calls++;
- ctdb_db->ctdb->statistics.pending_childwrite_calls++;
+ CTDB_INCREMENT_STAT(ctdb_db->ctdb, childwrite_calls);
+ CTDB_INCREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
if (!(result = talloc_zero(state, struct childwrite_handle))) {
- ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
return NULL;
}
if (ret != 0) {
talloc_free(result);
- ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
return NULL;
}
- result->child = fork();
+ result->child = ctdb_fork(ctdb_db->ctdb);
if (result->child == (pid_t)-1) {
close(result->fd[0]);
close(result->fd[1]);
talloc_free(result);
- ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
return NULL;
}
char c = 0;
close(result->fd[0]);
+ debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
ret = ctdb_persistent_store(state);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Failed to write persistent data\n"));
DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d for ctdb_childwrite\n", result->fd[0]));
result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0],
- EVENT_FD_READ|EVENT_FD_AUTOCLOSE, childwrite_handler,
+ EVENT_FD_READ, childwrite_handler,
(void *)result);
if (result->fde == NULL) {
talloc_free(result);
- ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+ CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
return NULL;
}
+ tevent_fd_set_auto_close(result->fde);
result->start_time = timeval_current();