diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2011-02-28 10:43:53 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-03-01 15:48:08 -0600 |
commit | 413eb0b8f7185e736d228736274e940d8f578c3d (patch) | |
tree | 65fd5888430538f750f9fd8ffc377a11044d1289 /src | |
parent | a324758bfd63d7b5a16a3ad4199f533309ecbd4c (diff) | |
download | ofono-413eb0b8f7185e736d228736274e940d8f578c3d.tar.bz2 |
location-reporting: don't add client-exit watch too early
Wait until driver gives us a file descriptor to start watching for
client exit. This fixes a race when client exits before the driver
calls location_reporting_enable_cb().
Diffstat (limited to 'src')
-rw-r--r-- | src/location-reporting.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/location-reporting.c b/src/location-reporting.c index 6ab09147..f19ccf5d 100644 --- a/src/location-reporting.c +++ b/src/location-reporting.c @@ -170,13 +170,12 @@ static void location_reporting_enable_cb(const struct ofono_error *error, int fd, void *data) { struct ofono_location_reporting *lr = data; + DBusConnection *conn = ofono_dbus_get_connection(); DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Enabling location-reporting failed"); - client_remove(lr); - reply = __ofono_error_failed(lr->pending); __ofono_dbus_pending_reply(&lr->pending, reply); @@ -184,6 +183,9 @@ static void location_reporting_enable_cb(const struct ofono_error *error, } lr->enabled = TRUE; + lr->client_owner = g_strdup(dbus_message_get_sender(lr->pending)); + lr->disconnect_watch = g_dbus_add_disconnect_watch(conn, + lr->client_owner, client_exited, lr, NULL); reply = dbus_message_new_method_return(lr->pending); dbus_message_append_args(reply, DBUS_TYPE_UNIX_FD, &fd, @@ -198,7 +200,6 @@ static DBusMessage *location_reporting_request(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_location_reporting *lr = data; - const char *caller = dbus_message_get_sender(msg); if (lr->pending != NULL) return __ofono_error_busy(msg); @@ -206,9 +207,6 @@ static DBusMessage *location_reporting_request(DBusConnection *conn, if (lr->enabled) return __ofono_error_in_use(msg); - lr->client_owner = g_strdup(caller); - lr->disconnect_watch = g_dbus_add_disconnect_watch(conn, - lr->client_owner, client_exited, lr, NULL); lr->pending = dbus_message_ref(msg); lr->driver->enable(lr, location_reporting_enable_cb, lr); |