/* Command line options (no config file options). Used in handle_sighup(). */
static struct lls_parse_result *cmdline_lpr;
-/** A random value used in child context for authentication. */
+/**
+ * A random number used to "authenticate" the afs connection.
+ *
+ * para_server picks this number by random before it forks the afs process. The
+ * command handlers know this number as well and write it to the afs socket,
+ * together with the id of the shared memory area which contains the payload of
+ * the afs command. A local process has to know this number to abuse the afs
+ * service provided by the local socket.
+ */
uint32_t afs_socket_cookie;
/** The mutex protecting the shared memory area containing the mmd struct. */
struct lls_parse_result *cf_lpr, *merged_lpr;
char *home = para_homedir();
- daemon_close_log();
if (OPT_GIVEN(CONFIG_FILE))
cf = para_strdup(OPT_STRING_VAL(CONFIG_FILE));
else
return 0;
}
-static void init_server_command_task(int argc, char **argv)
+static void init_server_command_task(struct server_command_task *sct,
+ int argc, char **argv)
{
int ret;
- static struct server_command_task server_command_task_struct,
- *sct = &server_command_task_struct;
PARA_NOTICE_LOG("initializing tcp command socket\n");
sct->argc = argc;
i = argc - lls_num_inputs(cmdline_lpr) - 1;
sprintf(argv[i], "para_server (afs)");
close(afs_server_socket[0]);
- afs_init(afs_socket_cookie, afs_server_socket[1]);
+ afs_init(afs_server_socket[1]);
}
close(afs_server_socket[1]);
if (read(afs_server_socket[0], &c, 1) <= 0) {
exit(EXIT_SUCCESS);
}
-static void server_init(int argc, char **argv)
+static void server_init(int argc, char **argv, struct server_command_task *sct)
{
int ret, afs_socket, daemon_pipe = -1;
char *errctx;
para_unblock_signal(SIGCHLD);
PARA_NOTICE_LOG("initializing virtual streaming system\n");
vss_init(afs_socket, &sched);
- init_server_command_task(argc, argv);
+ init_server_command_task(sct, argc, argv);
if (daemon_pipe >= 0) {
if (write(daemon_pipe, "\0", 1) < 0) {
PARA_EMERG_LOG("daemon_pipe: %s", strerror(errno));
int main(int argc, char *argv[])
{
int ret;
+ struct server_command_task server_command_task_struct,
+ *sct = &server_command_task_struct;
sched.default_timeout.tv_sec = 1;
sched.select_function = server_select;
- server_init(argc, argv);
+ server_init(argc, argv, sct);
mutex_lock(mmd_mutex);
ret = schedule(&sched);
sched_shutdown(&sched);