Commit Graph

30 Commits

Author SHA1 Message Date
Max Kellermann
36827e1134 event_pipe, test: explicitly ignore write() return value
Some compilers are very picky, but we really aren't interested in the
return value.
2012-03-19 20:37:25 +01:00
Max Kellermann
4f093d5b97 Merge branch 'v0.16.x'
Conflicts:
	Makefile.am
	NEWS
	configure.ac
	src/encoder/flac_encoder.c
	src/log.c
	src/pcm_buffer.c
2011-11-28 11:56:01 +01:00
Max Kellermann
04525c0259 event_pipe: fix WIN32 regression
The event pipe is not a socket, and the patch that introduced
g_io_channel_new_socket() to the event pipe library was wrong.
2011-10-13 09:08:37 +02:00
Max Kellermann
921553d7bb Merge branch 'v0.16.x' 2011-09-20 08:47:06 +02:00
Max Kellermann
b03f9ece05 glib_socket.h: wrap g_io_channel_*_new() calls portably
The server_socket library (used by the httpd output plugin) didn't
check for WIN32, that's fixed now.
2011-09-20 08:35:25 +02:00
Max Kellermann
c6cbcc2c25 copyright year 2011 2011-01-29 10:13:54 +01:00
Thomas Jansen
28bcb8bdf5 eliminate g_error() usage
Replaced all occurrences of g_error() with MPD_ERROR() located in a new header
file 'mpd_error.h'. This macro uses g_critical() to print the error message
and then exits gracefully in contrast to g_error() which would internally call
abort() to produce a core dump.

The macro name is distinctive and allows to find all places with dubious error
handling. The long-term goal is to get rid of MPD_ERROR() altogether. To
facilitate the eventual removal of this macro it was added in a new header
file rather than to an existing header file.

This fixes #2995 and #3007.
2010-09-25 15:00:43 +02:00
Denis Krjuchkov
e8ebb1af91 main: Add Windows Service support
I've added PIPE_EVENT_SHUTDOWN because calling g_main_loop_quit() do not work when called from another thread.
Main thread was sleeping in g_poll() so I needed some way to wake it up.

By some strange reason call close(event_pipe[0]) in event_pipe_deinit() hangs.
In current implementation that code never reached so that was not a problem :-)
I've added a conditional to leave event_pipe[0] open on Win32.
2010-09-23 20:42:33 +02:00
Max Kellermann
8248f498b2 event_pipe: use g_io_channel_read_chars() to drain the pipe
For some unknown reason, read() blocks on WIN32, even though it was
invoked inside the G_IO_IN callback.  By switching to GIOChannel
functions, this problem is solved, and it works on both Linux and
Windows.
2010-05-19 11:37:39 +02:00
Max Kellermann
22f3ffb099 event_pipe: call g_io_channel_win32_new_fd()
On WIN32, use g_io_channel_win32_new_fd() instead of
g_io_channel_unix_new().  There doesn't seem to be a practical
difference, but it seems more correct.
2010-05-19 11:37:22 +02: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
f66edccffd fd_util: added O_NONBLOCK functions
Changed the wrappers for pipe(), socket(), accept().  On WIN32, this
does not work for pipe().
2009-11-08 22:11:35 +01:00
Max Kellermann
e3af0032b2 set the close-on-exec flag on all file descriptors
Added the "fd_util" library, which attempts to use the new thread-safe
Linux system calls pipe2(), accept4() and the options O_CLOEXEC,
SOCK_CLOEXEC.  Without these, it falls back to FD_CLOEXEC, which is
not thread safe.

This is particularly important for the "pipe" output plugin (and
others, such as JACK/PulseAudio), because we were heavily leaking file
descriptors to child processes.
2009-11-07 18:55:16 +01: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
Sean McNamara
94479ca40f event_pipe can only be non-blocking if !WIN32 2009-03-27 18:03:46 +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
eac2da635d added G_LOG_DOMAIN macros to several libraries
Define the GLib logging domain in the following libraries: conf,
daemon, event_pipe, log.
2009-02-19 09:24:59 +01:00
Max Kellermann
e3c6ad515d event_pipe: remove the GLib source from the main context
Free memory before exiting.
2009-01-10 18:55:36 +01:00
Max Kellermann
21173ea4a9 event_pipe: removed the unused function event_pipe_wait() 2009-01-04 20:32:45 +01:00
Max Kellermann
38bf81285f utils: removed unused functions
Removed all allocation functions, xwrite(), xread(), ARRAY_SIZE().
Those have been superseded by GLib.
2009-01-03 14:53:42 +01:00
Max Kellermann
b42e10b839 event_pipe: use GLib logging 2009-01-03 14:53:39 +01:00
Max Kellermann
d1c4f261c8 event_pipe: use close() instead of xclose()
xclose() aims to be the signal safe version of close(). However during
cleanup, this isn't important.
2009-01-03 14:53:36 +01:00
Max Kellermann
fa9b5fd10b event_pipe: use _pipe() on WIN32
Windows has no pipe(), it only has _pipe() with two additional
parameters.
2009-01-03 13:22:55 +01:00
Max Kellermann
48aace1859 event_pipe: moved variable "main_task" to main.c 2009-01-03 13:19:01 +01:00
Max Kellermann
272ee5f7d2 event_pipe: replaced PIPE_EVENT_SIGNAL with main_notify
There is only one location using PIPE_EVENT_SIGNAL: to synchronize
player_command() with player_command_finished().  Use the "notify"
library instead of the event_pipe here.
2009-01-02 11:20:41 +01:00
Max Kellermann
e93136ef0f event_pipe: added event_pipe_emit_fast()
event_pipe_emit_fast() is aimed for use in signal handlers: it doesn't
lock the mutex, and doesn't log on error.  That makes it potentially
lossy, but for its intended use, that does not matter.
2009-01-01 18:47:25 +01:00
Max Kellermann
b3e2635ac1 event_pipe: added pipe_event enum and callbacks
Make the event_pipe (formerly main_notify) send/receive a set of
events, with a callback for each one.

The default event PIPE_EVENT_SIGNAL does not have a callback.  It
is still there for waking up the main thread, when it is waiting for
the player thread.
2009-01-01 18:22:11 +01:00
Max Kellermann
22bb5a5856 event_pipe: renamed functions from main_notify_* to event_pipe_*
Continuing the previous patch.
2009-01-01 18:12: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