aboutsummaryrefslogtreecommitdiffstats
path: root/src/event_pipe.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2011-01-29copyright year 2011Max Kellermann1-1/+1
2010-09-25eliminate g_error() usageThomas Jansen1-3/+4
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-23main: Add Windows Service supportDenis Krjuchkov1-0/+3
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-05-19event_pipe: use g_io_channel_read_chars() to drain the pipeMax Kellermann1-6/+14
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-19event_pipe: call g_io_channel_win32_new_fd()Max Kellermann1-0/+5
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.
2009-12-31Update copyright notices.Avuton Olrich1-1/+1
2009-11-12include config.h in all sourcesMax Kellermann1-0/+1
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-08fd_util: added O_NONBLOCK functionsMax Kellermann1-6/+1
Changed the wrappers for pipe(), socket(), accept(). On WIN32, this does not work for pipe().
2009-11-07set the close-on-exec flag on all file descriptorsMax Kellermann1-5/+2
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-04-01client, event_pipe: explicitly ignore the write() resultMax Kellermann1-1/+1
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-03-27event_pipe can only be non-blocking if !WIN32Sean McNamara1-0/+2
2009-03-13all: Update copyright header.Avuton Olrich1-8/+7
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-02-19added G_LOG_DOMAIN macros to several librariesMax Kellermann1-0/+3
Define the GLib logging domain in the following libraries: conf, daemon, event_pipe, log.
2009-01-10event_pipe: remove the GLib source from the main contextMax Kellermann1-1/+5
Free memory before exiting.
2009-01-04event_pipe: removed the unused function event_pipe_wait()Max Kellermann1-14/+4
2009-01-03utils: removed unused functionsMax Kellermann1-0/+3
Removed all allocation functions, xwrite(), xread(), ARRAY_SIZE(). Those have been superseded by GLib.
2009-01-03event_pipe: use GLib loggingMax Kellermann1-2/+3
2009-01-03event_pipe: use close() instead of xclose()Max Kellermann1-3/+2
xclose() aims to be the signal safe version of close(). However during cleanup, this isn't important.
2009-01-03event_pipe: use _pipe() on WIN32Max Kellermann1-2/+13
Windows has no pipe(), it only has _pipe() with two additional parameters.
2009-01-03event_pipe: moved variable "main_task" to main.cMax Kellermann1-5/+0
2009-01-02event_pipe: replaced PIPE_EVENT_SIGNAL with main_notifyMax Kellermann1-14/+4
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-01event_pipe: added event_pipe_emit_fast()Max Kellermann1-0/+8
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-01event_pipe: added pipe_event enum and callbacksMax Kellermann1-4/+67
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-01event_pipe: renamed functions from main_notify_* to event_pipe_*Max Kellermann1-12/+12
Continuing the previous patch.
2009-01-01main_notify: renamed source to event_pipe.cMax Kellermann1-1/+1
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.
2008-12-31main_notify: removed lock()/unlock()Max Kellermann1-10/+0
These functions are not used anymore since we use the GLib main loop.
2008-12-30main: use the GLib main loopMax Kellermann1-23/+13
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-30main_notify: make the read side of the pipe blockingMax Kellermann1-15/+6
Currently, both sides of the pipe are blocking, although we do not need blocking read(). Convert it back to blocking. Eliminate the select() from wait_main_task().
2008-12-30main_notify: removed notify object, use only pipeMax Kellermann1-34/+17
To wake up the main thread, don't attempt to use a GCond/GMutex (struct notify). This kind of mixed wakeup method has known race conditions. The idea behind this patch is: for wakeups which happen while the main thread is sleeping, use only a pipe. For wakeups which happen while the main thread is waiting for the player thread, we can later change to GCond. For now, accept the overhead of using a pipe for the latter. In the long run, the main thread will never wait for the player thread, but will do everything asynchronously.
2008-12-28update & main_notify: migrate from pthread to glib threadsThomas Jansen1-12/+17
2008-11-24main_notify.c: replaced mpd_unused by G_GNUC_UNUSEDThomas Jansen1-3/+5
2008-10-08don't include os_compat.hMax Kellermann1-0/+3
When there are standardized headers, use these instead of the bloated os_compat.h.
2008-10-08notify: removed the "Notify" typedefMax Kellermann1-1/+1
Typedefs shouldn't be used, use the bare struct names instead.
2008-10-06main_notify: define main_task so we can use it for assertionsEric Wong1-1/+2
It'll be easier to keep track of what code runs in what task/thread this way.
2008-09-26notify: protect notify->pending with the mutexMax Kellermann1-2/+0
There was a known deadlocking bug in the notify library: when the other thread set notify->pending after the according check in notify_wait(), the latter thread was deadlocked. Resolve this by synchronizing all accesses to notify->pending with the notify object's mutex. Since notify_signal_sync() was never used, we can remove it. As a consequence, we don't need notify_enter() and notify_leave() anymore; eliminate them, too.
2008-09-24notify: added notify_deinit()Max Kellermann1-0/+8
Destroy the mutex when it is not used anymore.
2008-09-23main_notify: removed assertion in wakeup_main_task()Max Kellermann1-2/+0
It is legal to call wakeup_main_task() from within the main thread, e.g. from within a signal handler. Remove the assertion.
2008-09-23main_notify: use init_async_pipe()Max Kellermann1-8/+1
Remove duplicated code.
2008-08-26use the notify library in main_notify.cMax Kellermann1-10/+7
Avoid some duplicated code in main_notify.c.
2008-04-17fix race condition in main_notify.cMax Kellermann1-1/+6
The function wait_main_task() is racy: if the function wakeup_via_cond() sees the mutex is locked just before wait_main_task() executes pthread_cond_wait(), the main thread blocks forever. Work around this issue by adding a "pending" flag just like in my notify.c code. A standards-compliant solution should be implemented later. git-svn-id: https://svn.musicpd.org/mpd/trunk@7365 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13main_notify: just use cond_signal to wakeup, no need to trylockEric Wong1-11/+1
pthread_cond_signal is a no-op if nothing is waiting on it git-svn-id: https://svn.musicpd.org/mpd/trunk@7351 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12main_notify: use pthread_cond_signal instead of broadcastEric Wong1-1/+1
signal is all we need since we only have one waiter and likely faster git-svn-id: https://svn.musicpd.org/mpd/trunk@7349 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Fix a deadlock after pause/nextEric Wong1-0/+1
Oops, forgot to unlock a mutex git-svn-id: https://svn.musicpd.org/mpd/trunk@7348 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12Fix the problem of songs not advancing without client activityEric Wong1-0/+130
The select() in the main event loop blocks now (saving us many unnecessary wakeups). This interacted badly with the threads that were trying to wakeup the main task via pthread_cond_signal() since the main task was not blocked on a condition variable, but on select(). So now if we detect a need to wakeup the player, we write to a pipe which select() is watching instead of blindly calling pthread_cond_signal(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7347 09075e82-0dd4-0310-85a5-a0d7c8717e4f