+/* Temporarily remove all this source's file descriptors from the
+ * poll(), so that if data comes available for one of the file descriptors
+ * we don't continually spin in the poll()
+ */
+/* HOLDS: source->context's lock */
+void
+block_source (GSource *source)
+{
+ GSList *tmp_list;
+
+ g_return_if_fail (!SOURCE_BLOCKED (source));
+
+ tmp_list = source->poll_fds;
+ while (tmp_list)
+ {
+ g_main_context_remove_poll_unlocked (source->context, tmp_list->data);
+ tmp_list = tmp_list->next;
+ }
+}
+
+/* HOLDS: source->context's lock */
+void
+unblock_source (GSource *source)
+{
+ GSList *tmp_list;
+
+ g_return_if_fail (!SOURCE_BLOCKED (source)); /* Source already unblocked */
+ g_return_if_fail (!SOURCE_DESTROYED (source));
+
+ tmp_list = source->poll_fds;
+ while (tmp_list)
+ {
+ g_main_context_add_poll_unlocked (source->context, source->priority, tmp_list->data);
+ tmp_list = tmp_list->next;
+ }
+}
+