Rename ->{pre,post}_select methods to ->{pre,post}_monitor. The word "monitor" is neutral and continues to be correct after the switch from select(2) to poll(2). Pure rename, nothing to see here.
stdin/stdout: Streamline documentation of {pre,post}_select(). Don't state the obvious and avoid talking about fd sets.
Hide implementation of para_fd_set(). This preparatory patch for replacing select() renames para_fd_set() to sched_fd_set(), moves it to sched.c and makes it static. All users are modified to call either of the two new public functions sched_monitor_{read,write}fd() which take a pointer to struct sched rather than an fd set pointer.
fd: Drop fd_set parameter from read_nonblock() and friends. This parameter is not necessary because its only purpose is to avoid the readv(2) system call in case it would likely return EAGAIN because we just called select(2) which reported that there is no data to read. Since the parameter is an obstacle for the conversion of the code base from select(2) to poll(2), get rid of it for the time being. If needed we can add back an equivalent optimization which checks for POLLIN after the conversion.
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 }'
stdin/stdout: Only set nonblock flags for non-tty fds. Although the ->post_select methods of all paraslash executables perform I/O only when select(2) reports that the file descriptor is ready, we set the O_NONBLOCK flag for all monitored fds. This is considered good practice because, in general, it might happen that a subsequent read(2) call blocks even if select(2) indicates that the fd is ready for reading. For example, an fd corresponding to a TCP socket might be flagged as ready for reading if a network packet with incorrect checksum has arrived, but a subsequent read(2) blocks until the packet has been retransmitted. However, stdin and stdout often correspond to a terminal device where the above scenario won't happen. Moreover, for terminals it's essential to reset the O_NONBLOCK flag to the old value on exit because the shell refers to the same file description and thus shares the file status flags, including O_NONBLOCK. Many terminal applications, for example dialog(1), expect stdout to be set to blocking mode and fail in arcane ways if O_NONBLOCK is set. When the stdin and stdout tasks are about to exit, they reset the file status flags back to the original values. However if "para_client stat" is killed with SIGINT, SIGTERM or SIGKILL, or put to sleep with SIGSTOP, the O_NONBLOCK flag remains set because para_client does not handle signals at all. para_recv, para_filter and para_write suffer from the same issue. Adding signal handling to these programs would not help in the SIGSTOP case because this signal can not be caught. This patch modifies stdin.c and stdout.c to no longer set O_NONBLOCK for fd 0 and fd 1 if these fds are associated with a terminal device. This is much easier and should do the job as well.
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.
Remove unnecessary system header includes. All these headers get included from para.h.
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
sched: Directly pass context pointer to pre/post_select(). The patch is large, but it's fairly straight forward: Instead of a task pointer all ->pre_select() and ->post_select() methods now receive the context pointer that was passed to the scheduler when the task was registered. This allows to kill the public task_context(). Two pre_select/post_select functions are not directly called by the scheduler: session_post_select(), generic_recv_pre_select(). These are changed to receive a proper struct rather than a void pointer. Note that generic_filter_pre_select() is not changed in this manner because some filters do not provide a pre_select wrapper but set task->pre_select to generic_filter_pre_select().
task_register() conversion: stdin task This renames stdin_set_defaults() to stdin_task_register() and changes the function to register the stdin task. Before this patch, the task was registered in the callers.
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
Merge branch 't/stdin_stdout_fixes' Was cooking for almost a month. b99b4a stdin/stdout: Restore fd flags on shutdown. Conflicts: stdin.c stdout.c
stdin/stdout: Restore fd flags on shutdown. The stdin/stdout code should restore the flags to the old value to avoid surprises, for example in shell scripts. This changes stdin.c and stdout.c to save the old value. It is restored in ->post_select when the buffer tree node is removed and no more I/O takes place.
sched: Rename new_post_select back to post_select.
sched: Kill old ->post_select variant. It has no more users.
stdin: Switch to the alternative post select method.
Change copyright year to 2013. Better late than never.
btr: Remove btr_free_node(). This has turned out to be source for bugs. Deallocate everything in btr_remove_node() hence making removing the node and freeing its resources an atomic operation. To avoid dangling pointers to freed btrn nodes, the argument of btr_remove_node() is changed to to struct btr_node **btrnp.
Change year in copyright message to 2012.