From 8149d2c7c98c60f7e236040334660eef3222211f Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sun, 14 Mar 2010 16:28:18 +0000 Subject: [PATCH] fix crash on app exit --- TODO.txt | 11 +++-------- src/l2cap.c | 12 +++++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/TODO.txt b/TODO.txt index 33e32fd10..fecc0aa42 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,12 +2,10 @@ 2009-11-08: Release 0.1 -DONE: -- BTstackManager activated/deactivated/discovery - NEXT: - BUG: bt_close crashes when used in CocoaTouch app -- BUG: BTdaemon crashes on iPhone when CocoaTouch app is closed +- add extern "C" to bstack methods + - see: http://stackoverflow.com/questions/376966/using-c-c-static-libraries-from-iphone-objectivec-apps - Provide BTstackManager Objective-C class - move connection methods to BTdevice (get more object oriented) - initWithAddress:(bd_addr_t *)addr @@ -17,15 +15,12 @@ NEXT: - figure out how to receive iPhone System Power IONotifications (in BTdaemon) to detect, when phone gets locked - some trick - use Cocoa run loop for background app? -- Add improved RFCOMM user-client - - use switch on RFCOMM control field in rfcomm.c packet handler - move RFCOMM code into BTdaemon +- add timeouts to cocoa run loop - L2CAP - segmentation -- add timeouts to cocoa run loop == Release 0.2 - Incoming L2CAP supported + improved Inq Dialog - - extend SpringBoard feedback - show alerts/messages using SpringBoardAcccess, e.g. Bluetooth disconnected by remote device - add code to notify about remote disconnets diff --git a/src/l2cap.c b/src/l2cap.c index 5c3011d49..508cdd9b3 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -495,7 +495,7 @@ void l2cap_unregister_service_internal(connection_t *connection, uint16_t psm){ l2cap_service_t *service = l2cap_get_service(psm); if (service) return; linked_list_remove(&l2cap_services, (linked_item_t *) service); - free( service ); + free(service); } // @@ -515,11 +515,13 @@ void l2cap_close_connection(connection_t *connection){ // unregister services l2cap_service_t *service; - for (it = (linked_item_t *) &l2cap_services; it ; it = it->next){ - channel = (l2cap_channel_t *) it->next; + for (it = (linked_item_t *) l2cap_services; it ; ){ + service = (l2cap_service_t *) it->next; if (service->connection == connection){ - it->next = it->next->next; - return; + it->next = service->item.next; + free(service); + } else { + it = it->next; } } }