summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-15 20:47:16 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-15 20:47:16 +0000
commitf587ce7845edb0eb01451368d01b5bc86b5904cd (patch)
treef3a549cd61df701882d818b5fc452b1438097f5b /test
parentf05f87a825ab8ed5273674a7f65521ffc526f0d2 (diff)
2003-03-15 Havoc Pennington <hp@pobox.com>
Make it pass the Hello handling test including all OOM codepaths. Now to do other messages... * bus/services.c (bus_service_remove_owner): fix crash when removing owner from an empty list of owners (bus_registry_ensure): don't leave service in the list of a connection's owned services if we fail to put the service in the hash table. * bus/connection.c (bus_connection_preallocate_oom_error): set error flag on the OOM error. * dbus/dbus-connection.c (_dbus_connection_new_for_transport): handle _dbus_transport_set_connection failure * dbus/dbus-transport-unix.c (_dbus_transport_new_for_fd): modify to create watches up front and simply enable/disable them as needed. (unix_connection_set): this can now fail on OOM * dbus/dbus-timeout.c, dbus/dbus-watch.c: add concept of enabling/disabling a watch or timeout. * bus/loop.c (bus_loop_iterate): don't touch disabled watches/timeouts * glib/dbus-gmain.c: adapt to enable/disable watches and timeouts
Diffstat (limited to 'test')
-rw-r--r--test/watch.c99
1 files changed, 55 insertions, 44 deletions
diff --git a/test/watch.c b/test/watch.c
index 73f5e97d..bdb18306 100644
--- a/test/watch.c
+++ b/test/watch.c
@@ -237,24 +237,28 @@ do_mainloop (void)
while (link != NULL)
{
DBusList *next = _dbus_list_get_next_link (&watches, link);
- int fd;
DBusWatch *watch;
- unsigned int flags;
watch = link->data;
-
- fd = dbus_watch_get_fd (watch);
- flags = dbus_watch_get_flags (watch);
-
- max_fd = MAX (max_fd, fd);
-
- if (flags & DBUS_WATCH_READABLE)
- FD_SET (fd, &read_set);
-
- if (flags & DBUS_WATCH_WRITABLE)
- FD_SET (fd, &write_set);
- FD_SET (fd, &err_set);
+ if (dbus_watch_get_enabled (watch))
+ {
+ int fd;
+ unsigned int flags;
+
+ fd = dbus_watch_get_fd (watch);
+ flags = dbus_watch_get_flags (watch);
+
+ max_fd = MAX (max_fd, fd);
+
+ if (flags & DBUS_WATCH_READABLE)
+ FD_SET (fd, &read_set);
+
+ if (flags & DBUS_WATCH_WRITABLE)
+ FD_SET (fd, &write_set);
+
+ FD_SET (fd, &err_set);
+ }
link = next;
}
@@ -266,10 +270,7 @@ do_mainloop (void)
while (link != NULL)
{
DBusList *next = _dbus_list_get_next_link (&watches, link);
- int fd;
DBusWatch *watch;
- unsigned int flags;
- unsigned int condition;
if (initial_watch_serial != watch_list_serial)
{
@@ -286,44 +287,52 @@ do_mainloop (void)
}
watch = link->data;
+
+ if (dbus_watch_get_enabled (watch))
+ {
+ int fd;
+ unsigned int flags;
+ unsigned int condition;
+
- fd = dbus_watch_get_fd (watch);
- flags = dbus_watch_get_flags (watch);
+ fd = dbus_watch_get_fd (watch);
+ flags = dbus_watch_get_flags (watch);
- condition = 0;
+ condition = 0;
- if ((flags & DBUS_WATCH_READABLE) &&
- FD_ISSET (fd, &read_set))
- condition |= DBUS_WATCH_READABLE;
+ if ((flags & DBUS_WATCH_READABLE) &&
+ FD_ISSET (fd, &read_set))
+ condition |= DBUS_WATCH_READABLE;
- if ((flags & DBUS_WATCH_WRITABLE) &&
- FD_ISSET (fd, &write_set))
- condition |= DBUS_WATCH_WRITABLE;
+ if ((flags & DBUS_WATCH_WRITABLE) &&
+ FD_ISSET (fd, &write_set))
+ condition |= DBUS_WATCH_WRITABLE;
- if (FD_ISSET (fd, &err_set))
- condition |= DBUS_WATCH_ERROR;
+ if (FD_ISSET (fd, &err_set))
+ condition |= DBUS_WATCH_ERROR;
- if (condition != 0)
- {
- WatchData *wd;
+ if (condition != 0)
+ {
+ WatchData *wd;
- wd = dbus_watch_get_data (watch);
+ wd = dbus_watch_get_data (watch);
- if (wd->type == WATCH_CONNECTION)
- {
- DBusConnection *connection = wd->data;
+ if (wd->type == WATCH_CONNECTION)
+ {
+ DBusConnection *connection = wd->data;
- dbus_connection_handle_watch (connection,
+ dbus_connection_handle_watch (connection,
+ watch,
+ condition);
+ }
+ else if (wd->type == WATCH_SERVER)
+ {
+ DBusServer *server = wd->data;
+
+ dbus_server_handle_watch (server,
watch,
condition);
- }
- else if (wd->type == WATCH_SERVER)
- {
- DBusServer *server = wd->data;
-
- dbus_server_handle_watch (server,
- watch,
- condition);
+ }
}
}
@@ -345,6 +354,7 @@ setup_connection (DBusConnection *connection)
if (!dbus_connection_set_watch_functions (connection,
(DBusAddWatchFunction) add_connection_watch,
(DBusRemoveWatchFunction) remove_connection_watch,
+ NULL,
connection,
NULL))
_dbus_assert_not_reached ("not enough memory");
@@ -359,6 +369,7 @@ setup_server (DBusServer *server)
if (!dbus_server_set_watch_functions (server,
(DBusAddWatchFunction) add_server_watch,
(DBusRemoveWatchFunction) remove_server_watch,
+ NULL,
server,
NULL))
_dbus_assert_not_reached ("not enough memory");