aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-09-20 11:11:54 -0300
committerAnderson Lizardo <anderson.lizardo@openbossa.org>2010-09-22 16:00:04 -0400
commitd74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c (patch)
tree3422571cffd685d2dbeca6f49ae05d9eaf9e35b2
parenta66ccf347bb1c319436c25e21fa17381c590aa3c (diff)
downloadbluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.tar.gz
bluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.tar.xz
bluez-d74b6fd61f4cf3b7d5953d3d1fc08fa2f663874c.zip
Remove the timeout source function when the example server exits
-rw-r--r--attrib/example.c9
-rw-r--r--attrib/example.h1
-rw-r--r--attrib/manager.c1
3 files changed, 10 insertions, 1 deletions
diff --git a/attrib/example.c b/attrib/example.c
index 21799892..76afce9b 100644
--- a/attrib/example.c
+++ b/attrib/example.c
@@ -59,6 +59,8 @@
#define FMT_KILOGRAM_UUID 0xA010
#define FMT_HANGING_UUID 0xA011
+static guint timeout_id = 0;
+
static gboolean change_battery_state(gpointer user_data)
{
static uint8_t state = 0x05;
@@ -163,7 +165,7 @@ static int register_attributes(void)
atval[0] = 0x04;
attrib_db_add(0x0110, &uuid, atval, 1);
- g_timeout_add_seconds(10, change_battery_state, NULL);
+ timeout_id = g_timeout_add_seconds(10, change_battery_state, NULL);
/* Thermometer: primary service definition */
sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
@@ -426,3 +428,8 @@ int server_example_init(void)
{
return register_attributes();
}
+
+void server_example_exit(void)
+{
+ g_source_remove(timeout_id);
+}
diff --git a/attrib/example.h b/attrib/example.h
index 5857e3fb..a2b07fe4 100644
--- a/attrib/example.h
+++ b/attrib/example.h
@@ -23,3 +23,4 @@
*/
int server_example_init(void);
+void server_example_exit(void);
diff --git a/attrib/manager.c b/attrib/manager.c
index a1b11493..31a3efc3 100644
--- a/attrib/manager.c
+++ b/attrib/manager.c
@@ -109,6 +109,7 @@ void attrib_manager_exit(void)
{
btd_unregister_device_driver(&client_driver);
+ server_example_exit();
attrib_client_exit();
dbus_connection_unref(connection);