summaryrefslogtreecommitdiff
path: root/http_send.c (follow)
Commit message (Collapse)AuthorAge
* Switch to SPDX identifiers.Andre Noll2026-03-17
| | | | | | | | 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.
* Move user_list.[ch] into server.[ch].Andre Noll2026-03-01
| | | | | | This works because only the server links with user_list.o. Since struct user contains a list head, list.h must now be included *before* server.h, which requires some trivial header shuffling in the .c files that include server.h.
* http_send.c: Simplify format_url().Andre Noll2026-01-26
| | | | | All callers pass an element of the listen_addresses[] array of struct sender_status, and these elements are never NULL.
* Move format_url() from net.c to http_send.c.Andre Noll2026-01-26
| | | | It's only needed there.
* Merge acl.c into http_send.c.Andre Noll2026-01-26
| | | | | Another small file whose functions are only called from http_send.c. This makes all acl functions static and dedoxifies them.
* Merge chunk_queue.c into http_send.c.Andre Noll2026-01-26
| | | | | | The former is only ~150 lines long and has no users outside of http_send.c. The merge allows us to mark the chunk queue related functions static, and some pointless doxygen comments can go away as well.
* http_send.c: Move header_sent to struct private_http_sender_data.Andre Noll2026-01-26
| | | | | The udp sender does not need it. Convert it to bool and initialize it because the private_data structure of the http sender is allocated without zeroing.
* http_send.c: Move chunk queue into struct private_http_sender_data.Andre Noll2026-01-26
| | | | | | | | | | | The udp sender does not need it, so it should not be part of the sender-independent sender_client structure. Since shutdown_client() needs to derive the private_http_sender_data structure from the ->private_data pointer of the sender_client pointer, the declaration of struct private_http_sender_data has to move up. Since this structure depends on the http_client_status enumeration, the declaration of the enumeration needs to move up as well.
* struct sender: Remove unused sched pointer argument of ->post_monitor().Andre Noll2026-01-26
| | | | | Only the http sender implements ->post_monitor(), and does not use the argument.
* struct sender: Remove unused chunks_sent parameter of ->send().Andre Noll2026-01-26
| | | | | Only the http sender sets ->send() (to http_send()), and this function ignores the parameter.
* http_send.c: Kill http_send_ok_msg() and http_send_err_msg().Andre Noll2026-01-26
| | | | Both are too simple to live and have only one caller.
* http_send.c: Remove trivial shutdown wrapper.Andre Noll2026-01-26
|
* http_send.c: Merge free_sender_status() into http_shutdown().Andre Noll2026-01-26
| | | | | Another wrapper which has become pointless after the merge of http_send.c with send_common.c.
* http_send.c: Merge init_sender_status() into http_send_init().Andre Noll2026-01-26
| | | | One is just a simple wrapper for the other, so we may as well combine the two.
* http_send.c: Rename or remove generic_foo().Andre Noll2026-01-26
| | | | | | None of these are generic anymore, and all but generic_com_on() have only one caller which is a trivial wrapper. Rename generic_com_on() to start_listening() and rename generic_foo() to http_foo() or merge the former into the latter.
* http_send.c: Remove sender_status pointer arguments.Andre Noll2026-01-26
| | | | | | | Since there is only one instance of this structure, all functions pass the same pointer value. Use the global pointer variable everywhere and remove the function parameters. To do so, the definition of the global instance needs to move to the top of the file.
* Move struct sender_status into http_send.c.Andre Noll2026-01-26
| | | | | It is only used there. In particular, the virtual streaming system does not need to know it.
* Move send_common.c into http_send.c.Andre Noll2026-01-26
| | | | | | | | | | | | With dccp gone, almost everything of send_common.c is specific to the http sender. The only exception is parse_fec_url(), which is called from com_sender() of command.c and from udp_send.c. Move this function to server.c and the rest to http_send.c. Make the latter static and dedoxify them. The generic_ function prefix indicates that the function works for both the http and the dccp transport. With dccp gone, this has become meaningless. We keep the prefix, though, to keep the patch small.
* Remove dccp.Andre Noll2026-01-26
| | | | | | | | | | | This removes all traces of dccp, specifically dccp_recv.c and dccp_send.c. The flowops related functions of net.c can go away as well, as flowops were only needed for the dccp transport. A few other functions are simplified by dropping the flowops or protocol parameter. Further cleanups are possible, but are deferred to subsequent commits. In particular, some functions of send_common.c are only called by the http transport now. These can be moved to http_send.c and then be made static.
* Move close_on_fork.c into server.c.Andre Noll2025-12-09
| | | | | | | | Two of the four functions exposed in close_on_fork.h are only called from server.c, the other two from the senders. The former two can now be made static. Since both were implemented as one-line wrappers of the static deplete_cof_list(), we keep only that, remove the wrappers and adjust the two callers.
* Improve sender documentation.Andre Noll2025-10-08
| | | | | | The new detailed description of send.h and the SENDER_SUBCOMMANDS macro, and a bunch of small improvements to the data structures and the public functions of send_common.c.
* http sender: Kill pointless macro.Andre Noll2025-05-26
| | | | The code is shorter and easier to read without the macro.
* Include regex.h from para.h.Andre Noll2025-05-19
| | | | Every .c file includes it anyway.
* fd: Improve read_pattern(), rename it to read_and_compare().Andre Noll2023-05-07
| | | | | | | | | | | | | | | | | | | 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.
* Merge topic branch t/overflow into masterAndre Noll2022-10-03
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This series implements a new memory allocation API which checks for overflows. The first part of the series just renames the main allocation functions. Later patches in the series implement allocators which take two size_t arguments (like calloc(3)) and check whether the multiplication overflows by employing the __builtin_mul_overflow() primitive supported by gcc and clang. This requires us to bump the lowest supported gcc and clang version. * refs/heads/t/overflow: build: Compile with -ftrapv. string: Introduce arr_zalloc(). string: Introduce arr_alloc(). string: Introduce arr_realloc() and check for integer overflow. string: Rename para_calloc() -> zalloc(). string: Rename para_malloc() -> alloc(). string: Overhaul para_strdup().
| * string: Rename para_malloc() -> alloc().Andre Noll2022-07-29
| | | | | | | | | | | | | | Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
* | Rename ->{pre,post}_select methods to ->{pre,post}_monitor.Andre Noll2022-08-25
| | | | | | | | | | | | | | 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.
* | Hide implementation of para_fd_set().Andre Noll2022-08-25
| | | | | | | | | | | | | | | | 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.
* | send: Avoid select-specific arguments in {pre,post}_select().Andre Noll2022-08-25
| | | | | | | | | | | | | | | | | | | | Just pass a pointer to struct sched instead of the fd sets. Since two of the prototypes declared in send.h now refer to this structure, sched.h must be included before send.h. The udp sender implements neither ->pre_select() nor ->post_select(), so we only need to fix the order in which send.h and sched.h are included.
* | net: Drop fd_set parameter from para_accept().Andre Noll2022-08-25
| | | | | | | | | | | | As for read_nonblock(), the parameter is dispensable because it is only used for an optimization to avoid a system call. Get rid of it because it hinders the conversion from select(2) to poll(2).
* | fd: Drop fd_set parameter from read_nonblock() and friends.Andre Noll2022-08-25
|/ | | | | | | | | | 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.
* vss: Fix harmless memory leaks at exit.Andre Noll2019-12-08
| | | | | | | The leaks were introduced in commit 4fbe16430b47 (server: Add --http-listen-address and --dccp-listen-address) from last year. Found by valgrind.
* Merge branch 'refs/heads/t/listen-address'Andre Noll2018-05-28
|\ | | | | | | | | | | | | | | | | | | | | | | A short series which adds options for para_server that allow the user to specify the listening addresses of the passive sockets. The resolution of the conflicts in server.c and send_common.c have been well tested and were cooking for a couple of weeks. * refs/heads/t/listen-address: server: Add --http-listen-address and --dccp-listen-address. server: Implement --listen-address for control service.
| * server: Add --http-listen-address and --dccp-listen-address.Andre Noll2018-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the http and the dccp sender accept connections on all IP addresses. This commit makes it possible to configure the senders to listen only on the specified subset of addresses. To make this work, the sender_status structure has to be extended to store an array of file descriptors rather than just a single one. Several places need to iterate over all listening sockets of the sender. The new FOR_EACH_LISTEN_FD macro helps to avoid duplicating the corresponding loop. The status part of the sender command now prints the listening addresses instead of just on/off. This is why we also maintain the ascii representation of the listening addresses in the sender_status structure and introduce the format_url() helper to format host/port pairs.
* | Merge branch 'refs/heads/t/clean_server_exit'Andre Noll2018-05-20
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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(). ...
| * sender: Deplete ACLs on exit.Andre Noll2018-03-13
| | | | | | | | | | This teaches the dccp and the http sender to empty their access control lists during shutdown, avoiding some (harmless) memory leaks at exit.
| * Remove some unused includes from {dccp,http}_send.c.Andre Noll2018-03-13
| | | | | | | | | | | | | | | | The access control and close on fork lists are handled in send_common.c, so the two senders do not need to know anything about them. The dccp sender does not perform chunk queuing, so it does not need to include chunk_queue.h.
| * server: Cleanly shut down senders on exit.Andre Noll2018-03-13
| | | | | | | | | | | | | | | | | | | | | | 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: Make array of senders constant.Andre Noll2018-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we define an array of static non-constant sender structures in vss.c with only ->init being initialized at compile time. At startup the ->init method of each sender must fill out the other function pointers of the structure. This approach is kind of pointless, as these pointers are known at compile time and never change. This patch changes the three senders to define a non-static constant sender structure instead. The vss maintains an array of pointers to these structures. Since the new sender structures are non-static, they need to be doxified. We use the opportunity to provide an overview of each sender. The patch also introduces FOR_EACH_SENDER(), a macro which is used several times to replace the open-coded loops we had before.
* | Move MAX_HOSTLEN from server.h to net.h.Andre Noll2018-04-17
| | | | | | | | | | | | 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.
* | send_common: Improve error diagnostics of generic_com_on().Andre Noll2018-04-17
|/ | | | | | | | | | | | Currently the function returns an error code but does not log a message on errors. The callers, http_send_init() and dccp_send_init(), print the strerror text with no indication that it is was generic_com_on() which caused the error. This commit moves the log messages from the callers to generic_com_on() and changes the return type of generic_com_on() to void because both callers now ignore the return value. The new log messages include a text which tells the user what went wrong.
* Shorten copyright notice.Andre Noll2017-09-22
| | | | | | | | | | | | | | | | | | | | | 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 }'
* Convert para_server to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | | | | | | | | 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.
* Avoid duplication of sender subcommands.Andre Noll2015-11-13
| | | | | | | | | | | | | | | | | | The list of sender subcommands (add, delete, allow, deny, on, off) is defined as an enumeration in send.h. This list is duplicated in check_sender_args() of command.c which contains the six subcommands as C-strings to be matched against the first word of the sender command line. For the code to work properly it is essential that the two subcommand lists are identical, which is a bad design that is quite error prone. Fortunately it is easy to avoid the duplication with a little preprocessor fu. Since the subcommands are spelled in lower case and there is no toupper function in CPP, we need to change the subcommand part of the enumeration constants to lower case. The bulk of the patch consists in trivial changes of all the users of these constants.
* Update year in copyright headers.Andre Noll2015-01-12
| | | | | | | | | | | | | | | | 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.
* Merge branch 'refs/heads/t/server_cmds'Andre Noll2014-10-09
|\ | | | | | | | | | | | | | | | | | | | | | | | | Was cooking for three weeks. * Add sender subcommand "status". * com_si(): Don't print git version string. * Doxify the sender_subcommand enum. * Overhaul help texts of server and afs commands. * com_sender: Replace memcpy by struct copy. Conflicts: command.c
| * Add sender subcommand "status".Andre Noll2014-08-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the si (server info) command prints information about each sender, like the number of connected clients and the access control lists. As this information is related to senders, the sender command seems to be a better fit. This commit introduces the new sender subcommand "status" for this purpose and changes com_si() to not print the sender information any more, making the output of com_si() bounded. It also renames the ->info() function of the senders to ->status() to make it clear that this function is related to the new status subcommand. The Networking paragraph of the manual is adjusted accordingly and now contains an example of the status command.
* | Make senders independent of afs and osl.Andre Noll2014-09-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although senders don't know anything about the osl databases of the audio file selector, all senders currently include afs.h and osl.h. This is because: * senders are part of para_server, so they include server.h, * server.h has an audio_file_data structure embedded in struct misc_meta_data, so struct audio_file_data must be declared before server.h is included, * struct audio_file_data is declared in afs.h, * afs.h makes use of structures defined in <osl.h>. This patch moves the declaration of struct audio_file_data from afs.h to afh.h, which is also included by all senders. This allows to remove the two include directives for afs.h and osl.h from all three senders.
* | doc: Change email address to maan@tuebingen.mpg.deAndre Noll2014-08-18
|/ | | | | | | | | | | | | | 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
* Merge branch 't/misc'Andre Noll2014-03-30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various fixes, improvements, cleanups. Cooking since 2014-02-22. * t/misc: (29 commits) build: Don't link with -lreadline if readline was not found. audiod: Skip NULL pointer check in compute_time_diff(). audiod: Make compute_time_diff() return void. com_stat(): Remove pointless uptime variable. gcrypt: Fix gcc warning on Ubuntu Lucid. flac: Try to link also without -logg. version.c: Fix comment of version_single_line(). doxygen: Expand all macros, in particular config.h. recv_common.c: Improve documentation of check_receiver_arg(). audiod: get_time_string() comment fix. configure: Really print opus audio file handler if opus lib was found. Overhaul doxygen main page. afs.h: Don't try to list all supported audio formats. Change copyright year to 2014. Add link to sideband.h in doxygen main page. Doxify error2.c and add GPL header. Add -Wdeclaration-after-statement. Add some missing includes. Makefile.real: Add clean2 to the list of phony targets. mood.c: Fix a trivial whitespace issue. ...