diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-05-06 01:20:42 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-05-06 01:20:42 +0000 |
commit | 6dd473cb823393b9dbfc370d64a039411664372d (patch) | |
tree | 8ceffb79cc43a2dfcae13926db7cb4a9ac3873af /serial | |
parent | d78c8f2dce3e97c62e71e07a5f78f1289db1dd58 (diff) |
Remove all serial ports on shutdown
Diffstat (limited to 'serial')
-rw-r--r-- | serial/manager.c | 2 | ||||
-rw-r--r-- | serial/port.c | 13 | ||||
-rw-r--r-- | serial/port.h | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/serial/manager.c b/serial/manager.c index 2bb1ce84..d0a21ce6 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -2295,6 +2295,8 @@ void serial_manager_exit(void) dbus_connection_unref(connection); connection = NULL; + port_release_all(); + if (rfcomm_ctl >= 0) close(rfcomm_ctl); } diff --git a/serial/port.c b/serial/port.c index c090ebd4..f2c0eb61 100644 --- a/serial/port.c +++ b/serial/port.c @@ -328,6 +328,19 @@ int port_remove_listener(const char *owner, const char *dev) return 0; } +void port_release_all(void) +{ + struct rfcomm_node *node; + GSList *l; + + for (l = connected_nodes; l; l = l->next) { + node = l->data; + + connected_nodes = g_slist_remove(connected_nodes, node); + rfcomm_node_free(node); + } +} + int port_register(DBusConnection *conn, int16_t id, bdaddr_t *src, bdaddr_t *dst, const char *dev, char *ppath, const char *svc) { diff --git a/serial/port.h b/serial/port.h index 88bcb200..5471525b 100644 --- a/serial/port.h +++ b/serial/port.h @@ -26,6 +26,8 @@ int port_add_listener(DBusConnection *conn, int16_t id, bdaddr_t *dst, int port_remove_listener(const char *owner, const char *dev); +void port_release_all(void); + int port_register(DBusConnection *conn, int16_t id, bdaddr_t *src, bdaddr_t *dst, const char *dev, char *ppath, const char *svc); |