| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
| |
The latter calls the former, both check for zero length but return different
error codes in this case. Avoid the redundant check, return consistent error
codes, and fix the type of the map pointer argument.
|
| |
|
|
|
|
|
|
|
|
| |
If this directory does not exist, para_play creates it at startup. However,
para_client and para_audioc do not do that, hence they fail to write the
history file on exit.
Teach para_client and para_audioc to create ~/.paraslash just as para_play
does. Replace para_mkdir() by create_dot_paraslash() as this is what all
callers need.
|
| |
|
|
| |
It's only used there.
|
| |
|
|
|
|
|
|
| |
Generated with
sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h
followed by manually tweaking the result a bit. No license change intended.
|
| |
|
|
| |
That's what the underlying call to writev(2) expects.
|
| |
|
|
|
|
|
| |
With only one user it can be static in aft.c. Modify the function
so that it no longer changes the current working directory, remove
para_opendir() because it is unused now, dedox the documentation and
streamline it a bit.
|
| |
|
|
|
|
| |
It has two callers which both pass the mode value 0777 and contain
extra code to regard the EEXIST error case as a success. Move the
common bits into the wrapper and improve the documentation.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The old name was a poor choice because the pattern argument actually
is neither a regular expression nor a filename pattern.
More importantly, the function receives a buffer size and tries
to read this many bytes but then compares only the first part of
the received buffer to the expected string. This is a rather weird
calling convention.
The only two callers are the http sender and receiver which both
call the function during the initial handshake where no other data is
available. Thus we can change the function to read only the minimal
amount of data (length of the expected string), and drop the bufsize
parameter.
Remove the unnecessary log message in the error case and streamline
the documentation while at it.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Another public trivial wrapper that can go away because it has only
a single caller. POSIX says
Upon successful completion, 0 shall be returned. Otherwise, −1 shall
be returned, the current working directory shall remain unchanged,
and errno shall be set to indicate the error.
So the new check against zero is equivalent to the old code which
checked whether the return value is non-negative.
|
| |
|
|
|
|
| |
Open-coding this function actually improves code readability. The
function name was a misnomer anyway because any error from the stat()
call (such as EACCES) was reported as "file does not exist".
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The select(2) API is kind of obsolete because it does not work for
file descriptors greater or equal than 1024, The general advice is
to switch to poll(2), which offers equivalent functionality and does
not suffer from this restriction. This patch implements this switch.
The fd sets of select(2) have one nice feature: One can determine in
O(1) time whether the bit for a given fd is turned on in an fd set.
For poll(2), the monitored file descriptors are organized in an array
of struct pollfd. Without information about the given fd's index in the
pollfd array, one can only perform a linear search which requires O(n)
time, with n being the number of fds being watched. Since this would
have to be done for each fd, the running time becomes quadratic in
the number of monitored fds, which is bad. Keeping the pollfd array
sorted would reduce that to n * log(n) at the cost of additional work
at insert time.
This patch implements a different approach. The scheduler now maintains
an additional array of unsigned integers which map fds to indices
into the pollfd array. This new index array is transparent to the
individual tasks, which still simply pass one or more fds from their
->pre_monitor() method to the scheduler. The length of the index array
equals the highest fd given. This might become prohibitive in theory,
but should not be an issue for the time being.
Care needs to be taken in order to deal with callers which ask for
the readiness of an fd without having called sched_monitor_readfd() or
sched_monitor_writefd() in the ->pre_monitor() step. Before the patch,
thanks to the FD_ZERO() call at the beginning of each iteration of
the scheduler's main loop, both sched_read_ok() and sched_write_ok()
returned false for fds which were not asked to be watched. We need
to keep it this way for a seamless transition.
We achieve this by replacing the FD_ZERO() call by a memset(3) call
which fills the index array with 0xff bytes. Both sched_read_ok() and
sched_write_ok() call the new get_revents() helper, where we check the
fd argument against the allocation sizes of the two arrays. If either
function is called with an fd that was not asked to be monitored in
the ->pre_monitor() step, the checks notice that the index of this
fd, 0xffffffff, is larger than the highest open fd and we return
"not ready for I/O".
Another issue is the case where the same file descriptor is submitted
twice in ->pre_monitor() to check for readiness with respect to both
reading and writing. The code in client_comon.c currently does that.
To keep it working, the scheduler needs to detect this case and re-use
the existing slot in both arrays.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
In analogy to write_ok(), introduce read_ok() which uses poll(2)
rather than select(2). To avoid duplications, abstract out the common
code to the new xpoll() helper.
We could avoid the timeout parameter of xpoll() at this point because
both callers call it with a zero timeout (causing poll() to return
immediately), but later patches introduce other callers which specify
non-zero timeouts.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This modifies the public struct sched so that users pass in the
default timeout as an integer value in milliseconds rather than
a struct timeval. This simplifies the code a little and eases the
transition from select(2) to poll(2) because poll(2) also takes a
plain integer for the timeout.
Since para_select() of fd.c now calls ms2tv() to convert the timeout
back to a struct timeval, all executables which link with fd.o must
also link with time.o. This was not the case for para_mixer and
para_audioc, so configure.ac needs to be adjusted accordingly.
|
| |
|
|
|
| |
It's only used there, so we can make it static and dedoxify its
documentation.
|
| |
|
|
|
| |
Both callers pass in a zero offset, so we can get rid of this
parameter.
|
| |
|
|
|
|
| |
file_exists() is in fact a misnomer, since it simply calls stat(2),
which may fail for many reasons besides ENOENT. But that's another
issue for another patch..
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
}'
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds infrastructure to support meta tag editing. If the new
--modify option is given to para_afh, the arguments to --title,
--artist, --album and --comment are used to alter the meta information
of the audio file. Only the wma audio format handler is extended
to support the new feature. Patches for other audio format handlers
follow.
As for the implementation, this commit adds the function pointer
->rewrite_tags to struct audio_format_handler. This function takes
a file descriptor to a newly opened temporary file. The individual
audio format handlers are supposed to write the altered contents to
this file descriptor. On success, the temporary file is renamed on
top of the original file unless --backup is given.
Since meta tags in wma files are encoded in UTF-16 we need primitives
to convert from UTF8 to UTF16 and vice versa. These are provided by
libiconv, so we check for this library and deactivate the new features
on systems that lack libiconv.
Unfortunately the signatures of iconv() are different between Linux
and FreeBSD. To deal with this incompatibility this patch adds a
configure check to determine if the cast is necessary.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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
|
| |
|
|
| |
Better late than never.
|
| |
|
|
|
|
|
|
|
|
| |
For the sideband API we will need to write two buffers one after
another. This patch adds the new public function xwritev() to fd.c
which takes an arbitrary number of buffers and calls writev() to
perform the write.
With this function in place, xwrite() becomes a trivial wrapper
for xwritev().
|
| |
|
|
|
|
| |
This function is not only useful for non-blocking file descriptors,
so the name was misleading. Rename it to xwrite() for the lack of
a better name.
|
| |
|
|
|
|
|
| |
These functions end up calling plain write(), hence they work on
arbitrary file descriptors, not just network sockets. So they really
belong to fd.c rather than to net.c. Rename the two functions to
write_buffer() and write_va_buffer().
|
| |
|
|
|
|
| |
Not a single caller actually checked the value of the passed
len pointer after the call, which is a sure sign for a bad API.
Just return the number of bytes written.
|
| | |
|
| |
|
|
| |
para_opendir() and para_fchdir() are only used inside fd.c.
|
| | |
|
| |
|
|
|
|
|
|
| |
This removes the redundant 'max_size_bytes' argument of
* write_nonblocking(),
* send_queued_chunks(), and
* send_chunk(),
since it was set to 0 in all cases.
|
| |
|
|
|
| |
Move it to fd.c and rename it to read_pattern(). Both users, http_recv.c and http_send.c,
are adjusted accordingly.
|
| |
|
|
|
|
| |
This simplifies the code quite a bit. In particular it allows to
kill the extra check for EAGAIN that was necessary to deal with
unreliable return value of FD_ISSET().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch is an attempt to create a better API for reads from
non-blocking file descriptors. It adds readv_nonblock() and implements
read_nonblock() as a simple wrapper for readv_nonblock(). Both new
functions check the given file descriptor for readability and read
as much as possible until an error occurs or the buffer is full.
Two additional parameters are introduced: An fd_set and a result
pointer for the number of bytes that have been read successfully. The
optional fd_set pointer is used to have the fixup code for unreliable
returns of FD_ISSET() at one place only.
Having an extra parameter for storing the number of bytes read allows
to treat EOF as an error condition but EAGAIN as a normal condition.
This will simplify callers (dccp_recv and upd_recv) a bit.
|
| |
|
|
| |
Hey, this is earlier than last year :)
|
| |
|
|
| |
This new function will be used by the dccp receiver in a subsequent patch.
|
| | |
|
| |
|
|
|
|
|
| |
para_mmap(): Do not exit on errors. Fix the only caller in vss.c
accordingly.
mmap_full_file(): Use para_mmap().
|
| |
|
|
| |
To this aim, move write_nonblock() from send_common.c to fd.c.
|
| | |
|
| | |
|
| |
|
|
|
| |
This way it can be used also for programs that don't need
networking.
|
| | |
|
| | |
|
| |
|
|
| |
Just to be consistent with mark_fd_blocking().
|
| |
|
|
| |
At least on NetBSD the fd returned by accept() might be in non-blocking
mode. So introduce mark_fd_blocking() and use it in handle_connect().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This obsoletes get_audio_file() of vss.c. It is being replaced
by a call to the afs layer from vss_post_select() which requests
a struct audio_format_data for the next audio file.
The afd struct, the chunk table and the path of the new audio file are
stored in a shared memory area. The id of that area is sent through
the afs-server socket. An open fd for the underlying audio file is
send to the server process as well using usual socket magic.
The vss task of the server process attaches the shared memory area
and mmaps the open fd to start audio streaming.
The code is still quite buggy, but let's do bug fixes and removal of
the old audio file selectors in susequent patches.
|
| |
|
|
|
|
|
|
| |
To make it independent from osl.c, we must not pass
a pointer to struct osl_data. Replace it by void *, size_t *
pointers. Also add new int *fd_ptr parameter. If it's non-NULL
the file is not closed after mmap, and the open fd is returned
in fd_ptr.
|
| | |
|