New server command: ll to change the log level at runtime. This makes use of the infrastructure introduced in the previous patch. However, the implementation of the ll command for para_server is more involved than its audiod counterpart because in the server case we have to tell two different processes (server and afs) to change their log level while the calling process, the command handler, does not need to set the loglevel because it is about to exit anyway. For the inter-process communication we introduce a new field in the mmd shared memory area so that command handlers can read the current value or set a new value. The log level propagates from there via daemon_set_loglevel() to the server and afs processes during each iteration of the scheduler loop where para_log() will pick it up to set the log level threshold for subsequent log events. The si command handler currently refers to the argument of the --loglevel server option to include the log level in its output. With dynamic log levels this no longer works because it always prints the value from the command line or the config file rather than the run time log level. Since the new ll command also prints the loglevel when it is executed with no arguments, we simply remove this line from the si output and hope that nobody cares. The si command handler was the last user of the ENUM_STRING_VAL macro in command.c. Removing the macro also allows us to make CMD_PTR local to server.c and to remove the lopsub definitions of the server suite from command.c. However, we still include the lopsub definitions of the server *command* suite (server_cmd.lsg.h) of course. We let any authenticated user run the command with no arguments to report the current loglevel but require full privileges to change the loglevel. Thus, the check for sufficient privileges needs to be performed in the command handler.
Merge branch 'refs/heads/t/clean_server_exit' This series removes many memory leaks of para_server by refactoring the shutdown and signal handling code. Most of the leaks happen only at shutdown and are hence harmless. But it is still good to plug the leaks because this puts more focus on real memory leaks in the valgrind output. The merge conflicted rather badly due to the changes introduced with the crypt branch that was merged last week. The resolution has been thoroughly tested, though. * refs/heads/t/clean_server_exit: (32 commits) command.c: Document return value of handle_connect(). user_list: Make list head static. afs: Allow database switching on sighup. afs: Free current mood or playlist on exit. afs: Free status items on exit. afs: Shutdown signals on exit. server: Free parse result also in afs. afs: Deplete user list at startup. server: Free audio file header on exit. sender: Deplete ACLs on exit. Remove some unused includes from {dccp,http}_send.c. server: Make argument of user_list_init() constant. server: Deplete user list on exit. server: Combine user_list_init() and populate(). server: Move para_fgets() to user_list.c. server: Initialize user list at compile time. server: Rename functions related to user lists. server: Constify return value of lookup_user(). server: Let stat command handler perform cleanup on signals. server: Have afs process close the current mood on exit(). ...
Move MAX_HOSTLEN from server.h to net.h. This generic networking-related constant does not belong to server.h. However, since server.h uses the constant, we have to make sure that net.h is included before server.h.
server: Free parse result also in afs. Both the server and the afs process need to access the lopsub parse result which is allocated and initialized prior to the fork(2) that creates the afs process. Hence both processes should free this memory on exit. The new public free_lpr() frees the memory allocated by both parse result structures.
server: Cleanly shut down senders on exit. This introduces ->shutdown for struct sender. Each of the three senders implements the new method to close file descriptors and to deallocate the resources occupied by the sender. The method is only called on exit via the new vss_shutdown() from both server and command handler context after schedule() returns. We need to introduce another helper, process_is_command_handler(), to distinguish between the two callers.
server: Shutdown the scheduler before handling commands. Currently the command handlers are called from the ->post_select method of the command task after the main server process has forked. When the command handler is done, it exits with the scheduler still active. This is not a problem per se, and it has been like this for more than a decade, but it does make it harder to debug memory leaks because we leak some resources. Valgrind complains about this, cluttering the output with pointless warnings. This commit cleans up the memory handling of the child process on exit. The command task of the child process notifies all tasks in its ->post_select method and then returns the new pseudo error code -E_CHILD_CONTEXT. This causes the scheduler to return to main(). The main() function checks via the new ->child_fd of struct server_command_task whether it is running in child context after schedule() has returned and calls the command handler in this case.
server: Move afs_pid out of mmd struct. The afs_pid variable is read-only after it has been initialized. Hence it does not qualify for being part of the shared memory area which contains the mmd struct. Make it a global variable instead.
server: Don't pass peername to handle_connect(). The only reason we pass it is that handle_connect() can print a log message containing the peer name. However, we already log this information right after the connection was accepted.
Shorten copyright notice. The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
Merge branch 'refs/heads/t/lopsub' The bulk of the changes in this release is the conversion of all command line parsers from gengetopt to lopsub. The series also contains a few cleanups that have become possible due to the switch from gengetopt to lopsub. The patches towards the end of the series rename para_fade to para_mixer. Naturally, the merge conflicted rather heavily against the other topic branches that have been merged since the lopsub branch was started. Conflicting files: Makefile.real afh.c afh_recv.c configure.ac osx_write.c write.c The resolutions for these conflicts were recorded with git rerere and have been tested for quite some time. Cooking for three weeks. * refs/heads/t/lopsub: (74 commits) audioc: Avoid double free in audioc_i9e_line_handler(). audiod: Avoid uninitialized memory access. Simplify mixer setup. mixer: Implement non-linear time scale for fading. mixer: Allow arbitrary relative time for sleep subcommand. Convert para_fade to subcommands, rename it to para_mixer. build: Create .dep files only during compilation. build: Simplify definition of $m4_lls_deps. build: Rename command list variables. build: Combine $(CFLAGS) and $(STRICT_CFLAGS). build: Let .d files depend only on .c. build: Don't create phony targets for dependencies. build: Remove duplicate dependency. build: Remove cmdline_dir and friends. build: Remove some unused variables from Makefile.real. build: Remove m4/gengetopt. Remove gengetopt and help2man checks from configure.ac. Remove man_util.bash. Remove ggo.c and ggo.h. manual: Do not mention gengetopt and help2man any more. ...
Convert para_server to lopsub. This is the last executable to be converted to lopsub. acl_init() is removed from acl.c, and the initialization of the access control list is moved to init_sender_status() of send_common.c. It now takes an lls_opt_result argument and calls acl_add_entry() for each argument given. The latter function needs to be made public. In dccp_send.c we check the FEC parameters and change the gengetopt config structure to contain the default values if invalid FEC parameters were given. With lopsub this is no longer possible as the lls_parse_result structure is opaque. We copy the FEC parameters to a dccp_fec_client structure anyway, so is it easiest to move the check there. The patch removes the unused gengetopt option files but leaves the gengetopt infrastructure of the build system in place. The build system will be cleaned up in subsequent patches.
server: Move ->size from mmd to struct vss_task. This field stores the size of the memory mapping of the current audio file, if any. No command handler ever changes the value, and the value is not read from com_stat(), so there is no reason for ->size to be part of the mmd shared memory area. Unlike ->size, the pointer to the mapping is stored in struct vss_task. Given that vss.c is the only file which reads ->map or ->size, it makes sense to store both values together in the vss task struct.
server.h: Improve documentation of mmd struct. This adds a sentence to the description of the structure which explains how the misc_meta_data structure is used for communication betweeen the server process and the command handlers. The patch also contains some minor language improvements.
Merge branch 'refs/heads/t/immediate-si-update' Cooking in next for four weeks. * aft: Store resolved paths when adding files. * aft: Update mtime and file size on afhi changes. * aft: Update status items on afs events. * aft.c: Pass struct ls_data pointer to make_status_items(). * afs: Simplify open_next_audio_file(). Conflicts: aft.c
server.h: Trivial whitespace/language cleanup.
aft: Update mtime and file size on afhi changes. If the current audio file is re-added to the osl database, for example because meta tags have changed, file size and modification time change. However, the paraslash stat command still shows the old values because currently the virtual streaming system calls fstat(2) only once when the audio file is opened and keeps reporting the resulting mtime and file size values until the file is closed. This commit introduces make_inode_status_items() which is called from make_status_items() on AFSI_CHANGE and AFHI_CHANGE events for the current audio file. The new function calls stat(2) on the path obtained from the current aft row. We can't use fstat(2) since (a) we don't have an open file descriptor any more and (b) this would not work anyway if the original file was overwritten. Due to the new helper, mmd->mtime can be removed. We must keep mmd->size though, since we need the original file size for the call to munmap().
Update year in copyright headers. Done with files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files In previous years we ran a similar script to set the second year in the range to the current year. This is kind of silly, so let's get rid of this useless information. This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in all file headers, i.e. only the first year (A) is left in. Accurate information including time stamps for each change can be obtained from the git history.
server: Add com_tasks(). It is sometimes useful to see the task list of para_server. The infrastructure for obtaining this information is already in sched.c, so this is a rather simple matter.
doc: Change email address to maan@tuebingen.mpg.de The mail server on systemlinux.org was down for more than a week lately, so let's use an alternative official address. This commit changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de. Most .c and .h files contain the email address in the copyright header, so they must all be patched. Three other files contain the address for a different reason: * README lists email and git, gitweb and home page URLs * configure.ac needs it for configure -h * version.c contains it for the -V option of all commands
Change copyright year to 2014. This year, we're really on time. The changes in this patch were created by the following silly script: files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files