示例#1
0
static int
queue_proc_init(struct passwd *pw, int server, const char *conf)
{
	uint32_t	version;
	int		fd;

	fd = fork_proc_backend("queue", conf, "queue-proc");
	if (fd == -1)
		fatalx("queue-proc: exiting");

	imsg_init(&ibuf, fd);

	version = PROC_QUEUE_API_VERSION;
	imsg_compose(&ibuf, PROC_QUEUE_INIT, 0, 0, -1,
	    &version, sizeof(version));

	queue_api_on_close(queue_proc_close);
	queue_api_on_message_create(queue_proc_message_create);
	queue_api_on_message_commit(queue_proc_message_commit);
	queue_api_on_message_delete(queue_proc_message_delete);
	queue_api_on_message_fd_r(queue_proc_message_fd_r);
	queue_api_on_message_corrupt(queue_proc_message_corrupt);
	queue_api_on_envelope_create(queue_proc_envelope_create);
	queue_api_on_envelope_delete(queue_proc_envelope_delete);
	queue_api_on_envelope_update(queue_proc_envelope_update);
	queue_api_on_envelope_load(queue_proc_envelope_load);
	queue_api_on_envelope_walk(queue_proc_envelope_walk);

	queue_proc_call();
	queue_proc_end();

	return (1);
}
示例#2
0
static int
queue_proc_init(struct passwd *pw, int server)
{
	int		sp[2];
	uint32_t	version;

	errno = 0;

	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) {
		log_warn("warn: queue-proc: socketpair");
		return (0);
	}

	if ((pid = fork()) == -1) {
		log_warn("warn: queue-proc: fork");
		goto err;
	}

	if (pid == 0) {
		/* child process */
		dup2(sp[0], STDIN_FILENO);
		if (closefrom(STDERR_FILENO + 1) < 0)
			exit(1);

		execl(execpath, "queue_ramproc", NULL);
		err(1, "execl");
	}

	/* parent process */
	close(sp[0]);
	imsg_init(&ibuf, sp[1]);

	version = PROC_QUEUE_API_VERSION;
	imsg_compose(&ibuf, PROC_QUEUE_INIT, 0, 0, -1,
	    &version, sizeof(version));

	queue_api_on_message_create(queue_proc_message_create);
	queue_api_on_message_commit(queue_proc_message_commit);
	queue_api_on_message_delete(queue_proc_message_delete);
	queue_api_on_message_fd_r(queue_proc_message_fd_r);
	queue_api_on_message_corrupt(queue_proc_message_corrupt);
	queue_api_on_envelope_create(queue_proc_envelope_create);
	queue_api_on_envelope_delete(queue_proc_envelope_delete);
	queue_api_on_envelope_update(queue_proc_envelope_update);
	queue_api_on_envelope_load(queue_proc_envelope_load);
	queue_api_on_envelope_walk(queue_proc_envelope_walk);

	queue_proc_call();
	queue_proc_end();

	return (1);

err:
	close(sp[0]);
	close(sp[1]);
	return (0);
}
示例#3
0
static int
queue_null_init(struct passwd *pw, int server)
{
	queue_api_on_message_create(queue_null_message_create);
	queue_api_on_message_commit(queue_null_message_commit);
	queue_api_on_message_delete(queue_null_message_delete);
	queue_api_on_message_fd_r(queue_null_message_fd_r);
	queue_api_on_message_corrupt(queue_null_message_corrupt);
	queue_api_on_envelope_create(queue_null_envelope_create);
	queue_api_on_envelope_delete(queue_null_envelope_delete);
	queue_api_on_envelope_update(queue_null_envelope_update);
	queue_api_on_envelope_load(queue_null_envelope_load);
	queue_api_on_envelope_walk(queue_null_envelope_walk);

	return (1);
}
示例#4
0
static int
queue_stub_init(int server)
{
	queue_api_on_message_create(queue_stub_message_create);
	queue_api_on_message_commit(queue_stub_message_commit);
	queue_api_on_message_delete(queue_stub_message_delete);
	queue_api_on_message_fd_r(queue_stub_message_fd_r);
	queue_api_on_message_corrupt(queue_stub_message_corrupt);
	queue_api_on_message_uncorrupt(queue_stub_message_uncorrupt);
	queue_api_on_envelope_create(queue_stub_envelope_create);
	queue_api_on_envelope_delete(queue_stub_envelope_delete);
	queue_api_on_envelope_update(queue_stub_envelope_update);
	queue_api_on_envelope_load(queue_stub_envelope_load);
	queue_api_on_envelope_walk(queue_stub_envelope_walk);
	queue_api_on_message_walk(queue_stub_message_walk);

	return 1;
}
示例#5
0
static int
queue_ram_init(struct passwd *pw, int server, const char * conf)
{
    tree_init(&messages);

    queue_api_on_message_create(queue_ram_message_create);
    queue_api_on_message_commit(queue_ram_message_commit);
    queue_api_on_message_delete(queue_ram_message_delete);
    queue_api_on_message_fd_r(queue_ram_message_fd_r);
    queue_api_on_message_corrupt(queue_ram_message_corrupt);
    queue_api_on_envelope_create(queue_ram_envelope_create);
    queue_api_on_envelope_delete(queue_ram_envelope_delete);
    queue_api_on_envelope_update(queue_ram_envelope_update);
    queue_api_on_envelope_load(queue_ram_envelope_load);
    queue_api_on_envelope_walk(queue_ram_envelope_walk);

    return (1);
}