Esempio n. 1
0
static void remove_child_pid(struct smbd_parent_context *parent,
			     pid_t pid,
			     bool unclean_shutdown)
{
	struct smbd_child_pid *child;
	struct server_id child_id;
	int ret;

	child_id = pid_to_procid(pid);

	ret = messaging_cleanup(parent->msg_ctx, pid);

	if ((ret != 0) && (ret != ENOENT)) {
		DEBUG(10, ("%s: messaging_cleanup returned %s\n",
			   __func__, strerror(ret)));
	}

	smbprofile_cleanup(pid);

	for (child = parent->children; child != NULL; child = child->next) {
		if (child->pid == pid) {
			struct smbd_child_pid *tmp = child;
			DLIST_REMOVE(parent->children, child);
			TALLOC_FREE(tmp);
			parent->num_children -= 1;
			break;
		}
	}

	if (child == NULL) {
		/* not all forked child processes are added to the children list */
		DEBUG(2, ("Could not find child %d -- ignoring\n", (int)pid));
		return;
	}

	if (unclean_shutdown) {
		/* a child terminated uncleanly so tickle all
		   processes to see if they can grab any of the
		   pending locks
                */
		DEBUG(3,(__location__ " Unclean shutdown of pid %u\n",
			(unsigned int)pid));
		if (parent->cleanup_te == NULL) {
			/* call the cleanup timer, but not too often */
			int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20);
			parent->cleanup_te = tevent_add_timer(parent->ev_ctx,
						parent,
						timeval_current_ofs(cleanup_time, 0),
						cleanup_timeout_fn,
						parent);
			DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n"));
		}
	}

	if (!serverid_deregister(child_id)) {
		DEBUG(1, ("Could not remove pid %d from serverid.tdb\n",
			  (int)pid));
	}
}
Esempio n. 2
0
static bool do_msg_cleanup(struct tevent_context *ev_ctx,
			   struct messaging_context *msg_ctx,
			   const struct server_id pid,
			   const int argc, const char **argv)
{
	int ret;

	ret = messaging_cleanup(msg_ctx, pid.pid);

	printf("cleanup(%u) returned %s\n", (unsigned)pid.pid,
	       ret ? strerror(ret) : "ok");

	return (ret == 0);
}