scheduler for the child.
Use ctdb_fork() from callers where we dont want the child to be running
at real-time privilege.
/* spawn a child process to marshall the huge log blob and send it back
to the ctdb tool using a MESSAGE
*/
- child = fork();
+ child = ctdb_fork(ctdb);
if (child == (pid_t)-1) {
DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n"));
return -1;
}
/*
- make ourselves slightly nicer: eg. a ctdb child.
+ * This function forks a child process and drops the realtime
+ * scheduler for the child process.
*/
-void ctdb_reduce_priority(struct ctdb_context *ctdb)
+pid_t ctdb_fork(struct ctdb_context *ctdb)
{
- errno = 0;
- if (nice(10) == -1 && errno != 0) {
- DEBUG(DEBUG_WARNING,("Unable to lower priority: %s\n",
- strerror(errno)));
+ pid_t pid;
+
+ pid = fork();
+ if (pid == 0) {
+ if (ctdb->do_setsched) {
+ ctdb_restore_scheduler(ctdb);
+ }
}
+ return pid;
}
void set_nonblocking(int fd)
bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
void ctdb_set_scheduler(struct ctdb_context *ctdb);
void ctdb_restore_scheduler(struct ctdb_context *ctdb);
+pid_t ctdb_fork(struct ctdb_context *ctdb);
int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
TDB_DATA indata,
return NULL;
}
- result->child = fork();
+ result->child = ctdb_fork(ctdb_db->ctdb);
if (result->child == (pid_t)-1) {
close(result->fd[0]);
return -1;
}
- ctdb->syslogd_pid = fork();
+ ctdb->syslogd_pid = ctdb_fork(ctdb);
if (ctdb->syslogd_pid == (pid_t)-1) {
printf("Failed to create syslog child process\n");
close(state->fd[0]);
goto free_log;
}
- *pid = fork();
+ *pid = ctdb_fork(ctdb);
/* Child? */
if (*pid == 0) {
return;
}
- child = fork();
+ child = ctdb_fork(ctdb);
if (child == (pid_t)-1) {
DEBUG(DEBUG_ERR,("Failed to fork() a notification child process\n"));
return;
return NULL;
}
- result->child = fork();
+ result->child = ctdb_fork(ctdb_db->ctdb);
if (result->child == (pid_t)-1) {
close(result->fd[0]);
return -1;
}
- state->child = fork();
+ state->child = ctdb_fork(ctdb);
if (state->child == (pid_t)-1) {
DEBUG(DEBUG_CRIT,(__location__ " fork() failed in check_reclock child\n"));
close(state->fd[0]);
return NULL;
}
- h->child = fork();
+ h->child = ctdb_fork(ctdb_db->ctdb);
if (h->child == (pid_t)-1) {
close(h->fd[0]);
return;
}
- child_ctx->child_pid = fork();
+ child_ctx->child_pid = ctdb_fork(ctdb);
if (child_ctx->child_pid == (pid_t)-1) {
close(child_ctx->fd[0]);
close(child_ctx->fd[1]);
sprintf(buf, "{ pstree -p; cat /proc/locks; ls -li /var/ctdb/ /var/ctdb/persistent; }"
" >/tmp/ctdb.event.%s.%d", tbuf, getpid());
- pid = fork();
+ pid = ctdb_fork(state->ctdb);
if (pid == 0) {
- ctdb_reduce_priority(state->ctdb);
system(buf);
/* Now we can kill the child */
kill(state->child, SIGTERM);