summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2158ae5)
raw | patch | inline | side by side (parent: 2158ae5)
author | Max Kellermann <max@duempel.org> | |
Fri, 16 Oct 2009 13:08:51 +0000 (15:08 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 16 Oct 2009 13:08:51 +0000 (15:08 +0200) |
mpd_glib_enter() is unreliable, because it does nothing when called
during the callback, which in turn was invoked by mpd_glib_leave().
Sometimes, mpdclient.idle is wrong because of that. This patch sets
mpdclient.idle to the return value of mpd_glib_enter().
during the callback, which in turn was invoked by mpd_glib_leave().
Sometimes, mpdclient.idle is wrong because of that. This patch sets
mpdclient.idle to the return value of mpd_glib_enter().
src/gidle.c | patch | blob | history | |
src/gidle.h | patch | blob | history | |
src/mpdclient.c | patch | blob | history |
diff --git a/src/gidle.c b/src/gidle.c
index d4fd8074351806ea56f7827e43848e1146097589..2165294723aa242c8d43f448e40bd42f985efc7e 100644 (file)
--- a/src/gidle.c
+++ b/src/gidle.c
source->io_events = events;
}
-void
+bool
mpd_glib_enter(struct mpd_glib_source *source)
{
bool success;
assert(!source->destroyed);
if (source->leaving)
- return;
+ return false;
source->idle_events = 0;
success = mpd_async_send_command(source->async, "idle", NULL);
if (!success) {
mpd_glib_invoke_async_error(source);
- return;
+ return false;
}
mpd_glib_add_watch(source);
+ return true;
}
bool
diff --git a/src/gidle.h b/src/gidle.h
index 6d17f76191b155f7073ac944a28a178fb36d7a97..240411612f1548eac560153db335f2866ef8308b 100644 (file)
--- a/src/gidle.h
+++ b/src/gidle.h
void
mpd_glib_free(struct mpd_glib_source *source);
-void
+/**
+ * Enters idle mode.
+ *
+ * @return true if idle mode has been entered, false if not
+ * (e.g. blocked during the callback, or I/O error)
+ */
+bool
mpd_glib_enter(struct mpd_glib_source *source);
/**
diff --git a/src/mpdclient.c b/src/mpdclient.c
index e380ac0dc8cae56102e4e5fb1fe680a7bcf97ef8..748baed5c1e99d42470254ea39240dcf3ff09753 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
assert(c->source == NULL || c->connection != NULL);
if (c->source != NULL && !c->idle) {
- c->idle = true;
- mpd_glib_enter(c->source);
+ c->idle = mpd_glib_enter(c->source);
}
}