-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-mainloop.c Main loop utility
*
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
*
- * Licensed under the Academic Free License version 1.2
+ * Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+#include <config.h>
#include "dbus-mainloop.h"
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define MAINLOOP_SPEW 0
+#if MAINLOOP_SPEW
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+static const char*
+watch_flags_to_string (int flags)
+{
+ const char *watch_type;
+
+ if ((flags & DBUS_WATCH_READABLE) &&
+ (flags & DBUS_WATCH_WRITABLE))
+ watch_type = "readwrite";
+ else if (flags & DBUS_WATCH_READABLE)
+ watch_type = "read";
+ else if (flags & DBUS_WATCH_WRITABLE)
+ watch_type = "write";
+ else
+ watch_type = "not read or write";
+ return watch_type;
+}
+#endif /* DBUS_ENABLE_VERBOSE_MODE */
+#endif /* MAINLOOP_SPEW */
+
struct DBusLoop
{
int refcount;
#if MAINLOOP_SPEW
_dbus_verbose (" skipping watch on fd %d as it was out of memory last time\n",
- dbus_watch_get_fd (wcb->watch));
+ dbus_watch_get_socket (wcb->watch));
#endif
}
else if (dbus_watch_get_enabled (wcb->watch))
flags = dbus_watch_get_flags (wcb->watch);
- fds[n_fds].fd = dbus_watch_get_fd (wcb->watch);
+ fds[n_fds].fd = dbus_watch_get_socket (wcb->watch);
fds[n_fds].revents = 0;
fds[n_fds].events = 0;
if (flags & DBUS_WATCH_READABLE)
fds[n_fds].events |= _DBUS_POLLOUT;
#if MAINLOOP_SPEW
- _dbus_verbose (" polling watch on fd %d\n", fds[n_fds].fd);
+ _dbus_verbose (" polling watch on fd %d %s\n",
+ fds[n_fds].fd, watch_flags_to_string (flags));
#endif
n_fds += 1;
else
{
#if MAINLOOP_SPEW
- _dbus_verbose (" skipping disabled watch on fd %d\n",
- dbus_watch_get_fd (wcb->watch));
+ _dbus_verbose (" skipping disabled watch on fd %d %s\n",
+ dbus_watch_get_socket (wcb->watch),
+ watch_flags_to_string (dbus_watch_get_flags (wcb->watch)));
#endif
}
}
_dbus_sleep_milliseconds (_dbus_get_oom_wait ());
}
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+#endif /* !DOXYGEN_SHOULD_SKIP_THIS */