Commit Graph

99 Commits

Author SHA1 Message Date
Max Kellermann c6cbcc2c25 copyright year 2011 2011-01-29 10:13:54 +01:00
Avuton Olrich 9d3865cb95 Update copyright notices. 2009-12-31 20:58:43 -08:00
Max Kellermann 5b82ffc291 include config.h in all sources
After we've been hit by Large File Support problems several times in
the past week (which only occur on 32 bit platforms, which I don't
have), this is yet another attempt to fix the issue.
2009-11-12 09:17:03 +01:00
Max Kellermann f78366910e client: splitted client.c into several pieces
The soure file client.c has nearly 1000 lines, time for splitting it
into smaller pieces to improve readability.
2009-07-28 17:17:23 +02:00
Max Kellermann c426bbcf95 client: moved struct client to client_internal.h
Prepare splitting client.c into several sources.
2009-07-28 16:42:40 +02:00
Max Kellermann 884201b919 client: moved some code to client_list_X()
Make the client list management a separate sub-library.
2009-07-23 19:20:30 +02:00
Max Kellermann a0afd0369f client: don't include socket headers
The client code uses portable GLib I/O functions and doesn't need the
OS specific socket headers.
2009-07-23 17:32:12 +02:00
Max Kellermann 09008cb0ec client: return "enum command_return" instead of "int"
Several functions work with the wrong return type, this patch fixes
them.
2009-07-19 15:53:48 +02:00
Max Kellermann faaf9dafe1 client: check "expired" flag again in client_write_output()
When client_defer_output() aborts the connection to the client,
client_write_output() called client_write_deferred() anyway.  This
caused an assertion failure.  Fix it by checking for the "expired"
flag again after client_defer_output() returns.
2009-06-04 08:59:33 +02:00
Max Kellermann 427dd81678 client: added assertions on channel!=NULL
I'm hunting down a bug where client->channel==NULL during I/O
operations.  These new assertions help avoid this kind of bug in the
future.
2009-06-04 08:42:02 +02:00
Max Kellermann d01d1ccad2 client: use GTimer to track timeouts 2009-04-25 14:16:24 +02:00
Max Kellermann c9c0415d65 client: free the fifo buffer
This patch fixes a memory leak: the fifo_buffer object was not freed
when the client connection was closed.
2009-04-17 11:37:27 +02:00
Max Kellermann 8ce2ec7aed client, event_pipe: explicitly ignore the write() result
On both locations, the result of write() can be ignored safely.  In
event_pipe_emit_fast(), that can only be "EAGAIN", which means that
the pipe buffer is full - no further notification required.  In
client_init(), that would be a fatal connection error, which would be
caught by the next event.

This patch fixes gcc warnings.
2009-04-01 17:14:25 +02:00
Avuton Olrich 98e81287e3 client: group static function declarations together. 2009-03-30 19:21:42 +02:00
Avuton Olrich 215cdda08d client: client_write() does not necessary for export. 2009-03-30 19:21:41 +02:00
Max Kellermann dccb973cfe client: use the new fifo_buffer library 2009-03-14 17:46:01 +01:00
Avuton Olrich 0aee49bdf8 all: Update copyright header.
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
2009-03-13 11:51:55 -07:00
Max Kellermann 5c10d2ded7 client: use sockaddr_to_string()
Removed the sockaddr_to_tmp_string() hack, use
the new function sockaddr_to_string() instead.
2009-02-28 15:20:35 +01:00
Max Kellermann 9dd00dfab7 client: removed duplicate "client" string from log
Since we introduced a GLib logging domain, the "client" string appears
twice in the log lines:

 client: client 0: command returned 0

Removed the second one, now it looks like this:

 client: [0] command returned 0

Still not quite good, but better than before.
2009-02-27 19:03:13 +01:00
Max Kellermann 76b217f71e client: check for G_IO_ERR and G_IO_HUP
When we do not explicitly catch G_IO_ERR and G_IO_HUP, GLib can go
into an infinite loop, because it won't deliver the socket error to
MPD.
2009-01-30 15:56:53 +01:00
Max Kellermann 8bc6bca555 client: use the GIOChannel for I/O
GIOChannel is more portable than raw read()/write() calls.  We're
using GIOChannel anyway, because we need it for plugging the client
into the GLib main loop.

Configure the GIOChannel to the bare minimum: no character set, no
buffering.
2009-01-25 19:54:57 +01:00
Max Kellermann b0ea975642 client: use GLib's win32 IO channel on WIN32
Use g_io_channel_win32_new_socket() instead of g_io_channel_unix_new()
on WIN32.
2009-01-25 19:40:10 +01:00
Max Kellermann a45922cd66 use g_free() instead of free()
On some platforms, g_free() must be used for memory allocated by
GLib.  This patch intends to correct a lot of occurrences, but is
probably not complete.
2009-01-25 18:47:21 +01:00
Max Kellermann 2362ee4a48 use config_get_positive() instead of manual parsing
Simplify some code by using config_get_positive(), instead of doing
manual parsing and validation each time.
2009-01-21 08:48:02 +01:00
Max Kellermann 4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann 0366adddbd client: remove "expire" event on exit 2009-01-10 18:55:39 +01:00
Max Kellermann 5e93d3682f added missing explicit config.h includes 2009-01-08 21:37:02 +01:00
Max Kellermann fa503e31e7 client: use GList instead of dlist.h
Get rid of the non-portable Linux list library, part I.
2009-01-07 16:30:40 +01:00
Max Kellermann 2bc0144023 client: use GLib instead of utils.h 2009-01-03 13:44:19 +01:00
Max Kellermann 0eb1166beb client: convert GREETING to a static string
The length of GREETING is known at compile time, don't use strlen().
2009-01-03 13:42:14 +01:00
Max Kellermann 9f5934d95b main_notify: renamed source to event_pipe.c
We are going to migrate away from the concept of notifying the main
thread.  There should be events sent to it instead.  This patch starts
a series to implement that.
2009-01-01 18:12:00 +01:00
Max Kellermann 3cd0b90ff6 client: run client_manager_expire() in an idle event
With the GLib main loop, the client manager can install its own event
in case a client is expired.  No need for main.c to call
client_manager_expire() manually.
2008-12-31 14:30:03 +01:00
Max Kellermann 2cdfd93830 client: remember GLib source id
Remove the event source from the GMainLoop object in
client_set_expired().
2008-12-31 00:29:27 +01:00
Max Kellermann d40cf1652d main: export the main_loop variable
Other libraries may need to access the main_loop reference, to add or
remove events, or to call g_main_loop_quit().
2008-12-30 19:50:22 +01:00
Max Kellermann 71e7ce5d8e main: use the GLib main loop
This is a rather huge patch, which unfortunately cannot be splitted.

Instead of using our custom ioops.h library, convert everything to use
the GLib main loop.
2008-12-30 19:24:39 +01:00
Max Kellermann 3c9992aead client: include winsock headers on WIN32
On Windows, socket declarations reside in winsock.h and ws2tcpip.h.
The POSIX headers sys/socket.h etc. are not available.
2008-12-29 17:42:43 +01:00
Max Kellermann 173021e4eb client: use GLib logging 2008-12-29 17:28:56 +01:00
Max Kellermann d2d11d70a8 client: always attempt to flush deferred buffers
When a response is very long (e.g. a large playlist > 100k songs),
most of it will end up in the deferred buffers.  Filling the deferred
queue is very expensive currently, because a new buffer is allocated
for every client_write() operation.  This may lead to long delays, and
the client might give up and disconnect meanwhile.  This patch makes
MPD attempt to flush the deferred queue as often as possible, to work
around this problem.  Due to the MPD 0.14 code freeze, we should not
optimize the buffering code now.
2008-12-24 03:00:08 +01:00
Thomas Jansen c06ce44768 replaced mpd_printf etc by G_GNUC_PRINTF
We want to remove gcc.h eventually. This takes care of all the G_GNUC_PRINTF
macros.
2008-12-02 03:00:02 +01:00
Thomas Jansen 843ed730c0 client.c: replaced mpd_unused by G_GNUC_UNUSED 2008-11-24 14:48:32 +01:00
Marc Pavot 0bad84066b command: allow clients to subscribe to specific idle events
The client may provide the names of idle events as arguments to the
"idle" command to inform MPD that it is only interested in these
events.
2008-11-22 13:26:21 +01:00
Max Kellermann a92903983d client: use bool
Return bool instead of int.
2008-10-31 13:58:00 +01:00
Max Kellermann 5ef17ac1aa client: don't try again after partial write
After a partial write, chances are vanishing that another write() will
succeed.  Don't try immediately.
2008-10-31 09:19:40 +01:00
Max Kellermann 94cbdffb72 client: use GQueue instead of sllist.h for deferred_send
Another custom data structore converted to GLib.
2008-10-31 09:18:11 +01:00
Max Kellermann 90e9079142 client: use GSList instead of struct strnode for command lists
Replace a custom data structure with a GLib one.
2008-10-31 09:17:56 +01:00
Max Kellermann e5ef2d8a37 client: removed list_cache
The list cache aims to save memory allocations, and complicates the
code a bit.  We should rather use GLib slices later, which are easy to
use.
2008-10-31 09:17:52 +01:00
Max Kellermann 51a6ee88f7 command: no CamelCase
Eliminate CamelCase in all public and static functions.
2008-10-22 21:40:44 +02:00
Max Kellermann 02a2a407c1 client: converted permissions to unsigned
client->permission is a bit set, and should be unsigned.
2008-10-17 23:53:28 +02:00
Max Kellermann f8d5b74071 client: eliminate variable "left" in client_write()
Reduce two temporary variables to only one.
2008-10-17 23:53:16 +02:00
Max Kellermann bdbccc633d client: fixed send buffer
There is no sense in using the kernel's send buffer size (SO_SNDBUF)
for MPD's send buffer.  Convert it into a static buffer of 4 kB.
2008-10-17 23:52:47 +02:00