aboutsummaryrefslogtreecommitdiffstats
path: root/src/interface.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* unsigned countersMax Kellermann2008-03-261-11/+11
| | | | | | | | Use unsigned variables for storing the count of items or for iteration variables. Since there can never be a negative number of items, it makes sense to use an unsigned data type here. This change is safe because the unsigned values are only used for adddressing array items. git-svn-id: https://svn.musicpd.org/mpd/trunk@7214 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* don't repeat select()Max Kellermann2008-03-261-5/+2
| | | | | | | | The interfaces main loop repeats the select() (non-blocking) after an event was handled. I do not see any reason for that, since all events should be handled after the first select(). This double select() does nothing than consume more CPU cycles. git-svn-id: https://svn.musicpd.org/mpd/trunk@7213 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* unlimited select() timeoutMax Kellermann2008-03-261-5/+3
| | | | | | | mpd sets a 1s select() timeout for no reason. This makes mpd wake up the CPU, consume some cycles just to see there is nothing to do. We can save that by specifying NULL instead of a timeout. git-svn-id: https://svn.musicpd.org/mpd/trunk@7212 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* networking: more assertions and cleanups to size_t/unsigned changesEric Wong2008-03-261-17/+25
| | | | | | | | | | | | Basically, I don't trust myself nor Max to not have bugs in our code when switching over to unsigned types, so I've added more assertions which will hopefully trip and force us to fix these bugs before somebody can exploit them :) Some cleanups for parameter parsing using strtol and error reporting to the user. Also, fix some completely garbled indentation in inputStream_http.c git-svn-id: https://svn.musicpd.org/mpd/trunk@7209 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use size_tMax Kellermann2008-03-261-24/+24
| | | | | | | | When dealing with in-memory lengths, the standard type "size_t" should be used. Missing one can be quite dangerous, because an attacker could provoke an integer under-/overflow, which may provide an attack vector. git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* zero is a valid file descriptorMax Kellermann2008-03-261-3/+3
| | | | | | | Although it may not happen in mpd code, it is perfectly possible for a newly allocated file descriptor to be zero. For theoretical correctness, allow 0. git-svn-id: https://svn.musicpd.org/mpd/trunk@7194 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface: abort if we expire while processing linesEric Wong2008-01-271-0/+2
| | | | | | | If we keep processing expired interfaces in a loop, we'll eventually close it and get fd < 0, causing assertions to fail. git-svn-id: https://svn.musicpd.org/mpd/trunk@7168 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ioops: make this zero-impact when compiling w/o zeroconf as wellEric Wong2008-01-031-49/+2
| | | | | | | This reduces the text size of the binary slightly when zeroconf support is not built, and keeps the interface code cleaner as well. git-svn-id: https://svn.musicpd.org/mpd/trunk@7133 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* zeroconf: reformat (with mpd-indent.sh + manual tweaks)Eric Wong2008-01-031-7/+7
| | | | | | | | | | Also, lower the impact of compiling this w/o zeroconf by making the init/teardown functions static no-ops. Eventually, we should separate the Bonjour and Avahi code into separate files and have callbacks registered for each one, avoiding the #ifdef mess we have now... git-svn-id: https://svn.musicpd.org/mpd/trunk@7132 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-15/+1
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface: fix IPV6 hostname buffer deallocation from automaticsEric Wong2007-09-011-12/+7
| | | | | | | | | | | | The host buffer that hostname pointed to is no longer on the stack by the time the SECURE() message is printed. So make it static and thus accessible to all. We won't be calling this stuff in the middle of a child process/thread/task, so there's no Also, hostname is a constant string we shouldn't modify, so mark it as const char *. git-svn-id: https://svn.musicpd.org/mpd/trunk@6842 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface: print whole debug message at onceJ. Alexander Treuman2007-08-271-7/+8
| | | | | | Using SECURE once without a \n, and again with one, results in a timestamp mid-line. Let's not do that. git-svn-id: https://svn.musicpd.org/mpd/trunk@6827 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a singleJ. Alexander Treuman2007-05-261-8/+4
| | | | | call to FATAL(). git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing "//" comments to "/* */" comments.J. Alexander Treuman2007-05-151-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* The massive copyright updateAvuton Olrich2007-04-051-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* This fixes a bug where a client sending just the right data could cause mpdJ. Alexander Treuman2007-03-181-0/+1
| | | | | | | | to segfault. This could be exploited by malicious users to crash other users' mpd. But more importantly, I believe clients are doing this unintentionally, and that this is what is causing mpd to segfault for many people after running for long periods of time. git-svn-id: https://svn.musicpd.org/mpd/trunk@5649 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't initialize globals to zero (or NULL)Eric Wong2007-01-141-6/+6
| | | | | | | | Some compilers and linkers aren't smart enough to optimize this, as global variables are implictly initialized to zero. As a result, binaries are a bit smaller as more goes in the .bss and less in the text section. git-svn-id: https://svn.musicpd.org/mpd/trunk@5254 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* avahi: more sparse fixes (-Wshadow, non-ANSI declarations)Eric Wong2007-01-141-8/+8
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5248 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Added zeroconf service publishing using avahiJim Ramsay2007-01-111-2/+60
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5238 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-3/+3
| | | | | | | | | | | | | | | | | | | I'm checking for zero-size allocations and assert()-ing them, so we can more easily get backtraces and debug problems, but we'll also allow -DNDEBUG people to live on the edge if they wish. We do not rely on errno when checking for OOM errors because some implementations of malloc do not set it, and malloc is commonly overridden by userspace wrappers. I've spent some time looking through the source and didn't find any obvious places where we would explicitly allocate 0 bytes, so we shouldn't trip any of those assertions. We also avoid allocating zero bytes because C libraries don't handle this consistently (some return NULL, some not); and it's dangerous either way. git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix a few warnings on 64-bit machinesEric Wong2006-08-181-2/+2
| | | | | | | | size_t is bigger than int on most 64-bit machines, so cast size_t to long when passing them to printf-like functions. Ideally we'd use %z, but many compilers don't support it. git-svn-id: https://svn.musicpd.org/mpd/trunk@4656 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Separate PROTOCOL_VERSION from VERSIONEric Wong2006-08-101-1/+1
| | | | | | So we can have VERSION=0.12.0rc1 and keep the clients seeing 0.12.0 git-svn-id: https://svn.musicpd.org/mpd/trunk@4608 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Several fixes uncovered with -pedanticEric Wong2006-08-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | playerData.c: proper error checking directory.c: properly check myFgets() for errors (it returns NULL on error) inputPlugins/mp3_plugin.c get rid of commas at the end of enums interface.c: we weren't using long long, so strtoll isn't needed get rid of void-pointer arithmetic sllist.c: get rid of void-pointer arithmetic compress.c: get rid of C++ comments, some compilers don't accept them Note that I personally like void pointer arithmetic, but some ancient compilers don't support them :( git-svn-id: https://svn.musicpd.org/mpd/trunk@4510 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix some warnings introduced in the big malloc-reduction patchEric Wong2006-07-301-0/+1
| | | | | | | The myfprintf bugs that are fixed here were NOT introduced in the last patch, it's just that the stricter warning checks from moving to fprintf caused string format bugs to actually be checked by gcc git-svn-id: https://svn.musicpd.org/mpd/trunk@4484 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface/connection malloc reductions from mpd-keEric Wong2006-07-301-175/+270
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch massively reduces the amount of heap allocations at the interface/command layer. Most commands with minimal output should not allocate memory from the heap at all. Things like repeatedly polling status, currentsong, and volume changes should be faster as a result, and more importantly, not a source of memory fragmentation. These changes should be safe in that there's no way for a remote-client to corrupt memory or otherwise do bad stuff to MPD, but an extra set of eyes to review would be good. Of course there's never any warranty :) No longer do we use FILE * structures in the interface, which means we don't have to allocate any new memory for most connections. Now, before you go on about losing the buffering that FILE * +implies+, remember that myfprintf() never took advantage of any of the stdio buffering features. To reduce the diff and make bugs easier to spot in the diff, I've kept myfprintf in places where we write to files (and not network interfaces). Expect myfprintf to go away entirely soon (we'll use fprintf for writing regular files). git-svn-id: https://svn.musicpd.org/mpd/trunk@4483 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-6/+6
| | | | | | Add a few new options for indent to try to make things a bit cleaner git-svn-id: https://svn.musicpd.org/mpd/trunk@4411 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-294/+300
| | | | | | Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* some quick hacks to avoid signedness warnings with gcc4Warren Dukes2006-07-171-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* sparse: ANSI-fy function declarationsEric Wong2006-07-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are just warnings from sparse, but it makes the output easier to read. I ran this through a quick perl script, but of course verified the output by looking at the diff and making sure the thing still compiles. here's the quick perl script I wrote to generate this patch: ----------- 8< ----------- use Tie::File; defined(my $pid = open my $fh, '-|') or die $!; if (!$pid) { open STDERR, '>&STDOUT' or die $!; exec 'sparse', @ARGV or die $!; } my $na = 'warning: non-ANSI function declaration of function'; while (<$fh>) { print STDERR $_; if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) { my ($f, $l, $pos, $func) = ($1, $2, $3, $4); $l--; tie my @x, 'Tie::File', $f or die "$!: $f"; print '-', $x[$l], "\n"; $x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/; print '+', $x[$l], "\n"; untie @x; } } git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Change shank's email addressJ. Alexander Treuman2006-07-141-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* [CLEANUP] Remove unused codeAvuton Olrich2006-07-141-32/+12
| | | | | Static what makes sense git-svn-id: https://svn.musicpd.org/mpd/trunk@4327 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* [CLEANUP] Remove unnecessary includes, staticAvuton Olrich2006-07-141-3/+3
| | | | | | functions that don't need to be exported, rename misspelled function git-svn-id: https://svn.musicpd.org/mpd/trunk@4325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Huge header update, update the copyright and addAvuton Olrich2006-07-131-1/+1
| | | | | the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* My first commit! :D Make sure the same interface isn't closed twice when ↵J. Alexander Treuman2006-05-101-1/+2
| | | | | max_command_list_size is exceeded, and don't abort mpd should the same interface be closed twice somewhere else. git-svn-id: https://svn.musicpd.org/mpd/trunk@4151 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* change a break; to a return statementWarren Dukes2005-08-181-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3444 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* attempt to fix an issue discoverred by jat with sending two close commands ↵Warren Dukes2005-08-181-0/+5
| | | | | back to back will cause an assert to fail git-svn-id: https://svn.musicpd.org/mpd/trunk@3442 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* change the default max_output_buffer_size from 2048 to 8192Warren Dukes2005-04-271-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3226 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* cleanup some debug codeWarren Dukes2005-03-191-14/+11
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3102 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix some signal handlingWarren Dukes2005-03-191-0/+11
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3101 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* *) slight code cleanupWarren Dukes2005-03-121-10/+15
| | | | | *) now --kill will not check for /proc/<pid>/exe (this is linux specific) git-svn-id: https://svn.musicpd.org/mpd/trunk@3063 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* make the "kill" command work againEric Wong2005-02-071-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2936 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix some casting issues in error messages for output buffer sizeWarren Dukes2004-12-221-5/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2812 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix an issue with errors and new read() code on interfaceWarren Dukes2004-11-161-3/+8
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2683 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* no longer need to include sig_handlers.h in interfac.ecWarren Dukes2004-11-141-1/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2651 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix a few bugs in read()'ingWarren Dukes2004-11-141-8/+9
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2650 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* optimized read() on clients, should be much, much faster nowWarren Dukes2004-11-141-121/+120
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2649 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ok, now song->url is only the filename, not the full path to the songWarren Dukes2004-11-111-4/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2602 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* now one can specify multiple bind_to_addressesWarren Dukes2004-11-031-3/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2501 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* we need to initialize interface_max_connections to 0, to indicate we have ↵Warren Dukes2004-10-311-1/+3
| | | | | no open/possible interfaces for interfacePrintWithFD() (i.e. so we don't get a segfault when creating the db, or other potential problems) git-svn-id: https://svn.musicpd.org/mpd/trunk@2434 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* merge shank-rewrite-config changesWarren Dukes2004-10-281-25/+56
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f