aboutsummaryrefslogtreecommitdiffstats
path: root/src/interface.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-01-27interface: abort if we expire while processing linesEric Wong1-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
2008-01-03ioops: make this zero-impact when compiling w/o zeroconf as wellEric Wong1-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
2008-01-03zeroconf: reformat (with mpd-indent.sh + manual tweaks)Eric Wong1-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
2008-01-03Cleanup #includes of standard system headers and put them in one placeEric Wong1-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
2007-09-01interface: fix IPV6 hostname buffer deallocation from automaticsEric Wong1-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
2007-08-27interface: print whole debug message at onceJ. Alexander Treuman1-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
2007-05-26Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a singleJ. Alexander Treuman1-8/+4
call to FATAL(). git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-05-15Changing "//" comments to "/* */" comments.J. Alexander Treuman1-3/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@6112 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-04-05The massive copyright updateAvuton Olrich1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-03-18This fixes a bug where a client sending just the right data could cause mpdJ. Alexander Treuman1-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
2007-01-14Don't initialize globals to zero (or NULL)Eric Wong1-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
2007-01-14avahi: more sparse fixes (-Wshadow, non-ANSI declarations)Eric Wong1-8/+8
git-svn-id: https://svn.musicpd.org/mpd/trunk@5248 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-01-11Added zeroconf service publishing using avahiJim Ramsay1-2/+60
git-svn-id: https://svn.musicpd.org/mpd/trunk@5238 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-08-26Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong1-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
2006-08-18fix a few warnings on 64-bit machinesEric Wong1-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
2006-08-10Separate PROTOCOL_VERSION from VERSIONEric Wong1-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
2006-08-01Several fixes uncovered with -pedanticEric Wong1-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
2006-07-30fix some warnings introduced in the big malloc-reduction patchEric Wong1-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
2006-07-30interface/connection malloc reductions from mpd-keEric Wong1-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
2006-07-20Add mpd-indent.shAvuton Olrich1-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
2006-07-20Add mpd-indent.shAvuton Olrich1-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
2006-07-17some quick hacks to avoid signedness warnings with gcc4Warren Dukes1-2/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@4387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-17sparse: ANSI-fy function declarationsEric Wong1-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
2006-07-14Change shank's email addressJ. Alexander Treuman1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-14[CLEANUP] Remove unused codeAvuton Olrich1-32/+12
Static what makes sense git-svn-id: https://svn.musicpd.org/mpd/trunk@4327 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-14[CLEANUP] Remove unnecessary includes, staticAvuton Olrich1-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
2006-07-13Huge header update, update the copyright and addAvuton Olrich1-1/+1
the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-05-10My first commit! :D Make sure the same interface isn't closed twice when ↵J. Alexander Treuman1-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
2005-08-18change a break; to a return statementWarren Dukes1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@3444 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-08-18attempt to fix an issue discoverred by jat with sending two close commands ↵Warren Dukes1-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
2005-04-27change the default max_output_buffer_size from 2048 to 8192Warren Dukes1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@3226 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-03-19cleanup some debug codeWarren Dukes1-14/+11
git-svn-id: https://svn.musicpd.org/mpd/trunk@3102 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-03-19fix some signal handlingWarren Dukes1-0/+11
git-svn-id: https://svn.musicpd.org/mpd/trunk@3101 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-03-12*) slight code cleanupWarren Dukes1-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
2005-02-07make the "kill" command work againEric Wong1-2/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@2936 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-12-22fix some casting issues in error messages for output buffer sizeWarren Dukes1-5/+6
git-svn-id: https://svn.musicpd.org/mpd/trunk@2812 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-16fix an issue with errors and new read() code on interfaceWarren Dukes1-3/+8
git-svn-id: https://svn.musicpd.org/mpd/trunk@2683 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-14no longer need to include sig_handlers.h in interfac.ecWarren Dukes1-1/+0
git-svn-id: https://svn.musicpd.org/mpd/trunk@2651 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-14fix a few bugs in read()'ingWarren Dukes1-8/+9
git-svn-id: https://svn.musicpd.org/mpd/trunk@2650 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-14optimized read() on clients, should be much, much faster nowWarren Dukes1-121/+120
git-svn-id: https://svn.musicpd.org/mpd/trunk@2649 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-11ok, now song->url is only the filename, not the full path to the songWarren Dukes1-4/+6
git-svn-id: https://svn.musicpd.org/mpd/trunk@2602 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-03now one can specify multiple bind_to_addressesWarren Dukes1-3/+2
git-svn-id: https://svn.musicpd.org/mpd/trunk@2501 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-10-31we need to initialize interface_max_connections to 0, to indicate we have ↵Warren Dukes1-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
2004-10-28merge shank-rewrite-config changesWarren Dukes1-25/+56
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-07-12potential fixes for NHI\'s bugsWarren Dukes1-1/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@1848 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-15fix C99 stuff for commandErrorWarren Dukes1-8/+9
also some slight optimizations to interfacePrintWithFD() and myfprintf() git-svn-id: https://svn.musicpd.org/mpd/trunk@1503 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-05implement list_OK/command_list_ok_beginWarren Dukes1-15/+17
update COMMANDS git-svn-id: https://svn.musicpd.org/mpd/trunk@1344 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-04finish ack error codesWarren Dukes1-0/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@1325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-04clean up ACK error coding a little bitWarren Dukes1-8/+6
git-svn-id: https://svn.musicpd.org/mpd/trunk@1321 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-05-11fix foobar!Warren Dukes1-1/+1
git-svn-id: https://svn.musicpd.org/mpd/trunk@993 09075e82-0dd4-0310-85a5-a0d7c8717e4f