/*
- * Copyright (C) 1997-2013 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2014 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file server.c Paraslash's main server. */
-
/**
- * \mainpage Starting points for getting an overview:
+ * \mainpage Main data structures:
*
- * - The main programs: \ref server.c, \ref audiod.c, \ref client.c,
- * \ref audioc.c, \ref afh.c, \ref play.c,
* - Server: \ref server_command, \ref sender,
- * - Audio file selector: \ref audio_format_handler, \ref afs_table,
- * - Client: \ref receiver, \ref receiver_node, \ref filter,
- * \ref filter_node, \ref writer_node.
- *
- *
- * The gory details, listed by topic:
+ * - Audio file selector: \ref afs_info, \ref afs_table,
+ * - Audio format handler: \ref audio_format_handler, \ref afh_info
+ * - Receivers/filters/writers: \ref receiver, \ref receiver_node,
+ * \ref filter, \ref filter_node, \ref writer_node, \ref writer.
*
- * - Audio format handlers: \ref send_common.c \ref mp3_afh.c,
- * \ref ogg_afh.c, \ref aac_afh.c, \ref wma_afh.c, \ref spx_afh.c
- * - Decoders: \ref mp3dec_filter.c, \ref oggdec_filter.c,
- * \ref aacdec_filter.c, \ref wmadec_filter.c, spxdec_filter.c,
- * \ref flacdec_filter.c,
- * - Volume normalizer: \ref compress_filter.c,
- * - Output: \ref alsa_write.c, \ref osx_write.c, \ref oss_write.c,
- * - http: \ref http_recv.c, \ref http_send.c,
- * - udp: \ref udp_recv.c, \ref udp_send.c,
- * - dccp: \ref dccp_recv.c, \ref dccp_send.c,
- * - Audio file selector: \ref afs.c, \ref aft.c, \ref mood.c,
- * - Afs structures: \ref afs_table, \ref audio_file_data,
- * \ref afs_info \ref afh_info,
- * - Afs tables: \ref aft.c, \ref mood.c, \ref playlist.c,
- * \ref attribute.c, \ref score.c,
- * - The virtual streaming system: \ref vss.c, \ref chunk_queue.c.
+ * Selected APIs:
*
- * Lower levels:
- *
- * - Scheduling: \ref sched.c, \ref sched.h,
- * - Networking: \ref net.c,
- * - File descriptors: \ref fd.c,
- * - Signals: \ref signal.c,
- * - Daemons: \ref daemon.c,
- * - Strings: \ref string.c, \ref string.h,
+ * - Scheduling: \ref sched.h,
+ * - Buffer trees: \ref buffer_tree.h,
+ * - Sideband API: \ref sideband.h,
+ * - Crypto: \ref crypt.h, \ref crypt_backend.h,
+ * - Error subsystem: \ref error.h, \ref error2.c,
+ * - Inter process communication: \ref ipc.h,
+ * - Forward error correction: \ref fec.h,
+ * - Daemons: \ref daemon.h,
+ * - Mixer API: \ref mix.h,
+ * - Interactive sessions: \ref interactive.h,
+ * - File descriptors: \ref fd.h,
+ * - Signals: \ref signal.h,
+ * - Networking: \ref net.h,
* - Time: \ref time.c,
- * - Spawning processes: \ref exec.c,
- * - Inter process communication: \ref ipc.c,
- * - Blob tables: \ref blob.c,
- * - The error subsystem: \ref error.h.
- * - Access control for paraslash senders: \ref acl.c, \ref acl.h.
- * - Internal crypto API: \ref crypt.h.
- * - interactive sessions (libreadline): \ref interactive.c.
- *
- * Low-level data structures:
- *
- * - Doubly linked lists: \ref list.h,
- * - Ring buffer: \ref ringbuffer.c, \ref ringbuffer.h,
- * - openssl: \ref crypt.c
- * - libgcrypt: \ref gcrypt.c
- * - Forward error correction: \ref fec.c.
+ * - Doubly linked lists: \ref list.h.
*/
+#include <netinet/in.h>
+#include <sys/socket.h>
#include <signal.h>
#include <regex.h>
#include <osl.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <sys/un.h>
+#include <netdb.h>
#include "para.h"
#include "error.h"
/** Argument vector passed to para_server's main function. */
char **argv;
/** The command task structure for scheduling. */
- struct task task;
+ struct task *task;
};
static int want_colors(void)
static void command_pre_select(struct sched *s, struct task *t)
{
- struct server_command_task *sct = container_of(t, struct server_command_task, task);
+ struct server_command_task *sct = task_context(t);
para_fd_set(sct->listen_fd, &s->rfds, &s->max_fileno);
}
static int command_post_select(struct sched *s, struct task *t)
{
- struct server_command_task *sct = container_of(t, struct server_command_task, task);
+ struct server_command_task *sct = task_context(t);
int new_fd, ret, i;
char *peer_name;
*sct = &server_command_task_struct;
PARA_NOTICE_LOG("initializing tcp command socket\n");
- sct->task.pre_select = command_pre_select;
- sct->task.post_select = command_post_select;
sct->argc = argc;
sct->argv = argv;
ret = para_listen_simple(IPPROTO_TCP, conf.port_arg);
if (ret < 0)
goto err;
add_close_on_fork_list(sct->listen_fd); /* child doesn't need the listener */
- sprintf(sct->task.status, "server command task");
- register_task(&sched, &sct->task);
+ sct->task = task_register(&(struct task_info) {
+ .name = "server command",
+ .pre_select = command_pre_select,
+ .post_select = command_post_select,
+ .context = sct,
+ }, &sched);
return;
err:
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
server_init(argc, argv);
mutex_lock(mmd_mutex);
ret = schedule(&sched);
+ sched_shutdown(&sched);
if (ret < 0) {
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);