GNOME Bugzilla – Bug 495278
g-p-m does not detect when the phone gets disconnected
Last modified: 2011-02-17 22:54:59 UTC
I run g-p-m, it connected to the phone successfully. Then I moved with the phone out of the laptop range (you may simulate this by disabling bluetooth in the phone). g-p-m did not notice this and still shows "Connected" status. After getting in range again, when trying to send the message, gui gets frozen.
That's caused by the bluetooth read() never returning when the device goes out of range. Once that code is fixed in gnokii, we'll need to do some changes to the listener so that it cleans up the connection properly on unrecoverable errors.
That's fixed in gnokii CVS. With every driver and every connection type, gnokii should not hang anymore.
Which error does gn_sm_functions() return when the phone is out of range now? Once we know what it is, we simply need to tell the front-end that we've disconnected.
GN_ERR_NOTREADY
Created attachment 112506 [details] g-p-m debug output Here is the log from g-p-m 0.51 when I start it and connect to my phone and then move my phone away so that it gets outside of the bluetooth range.
2008-06-11 Bastien Nocera <hadess@hadess.net> * libgsm/phonemgr-listener.c (phonemgr_listener_gnokii_func), (phonemgr_listener_connect), (phonemgr_listener_cell_not_cb), (phonemgr_listener_sms_notification_soft_poll), (phonemgr_listener_battery_poll), (phonemgr_listener_get_own_details), (phonemgr_listener_set_sms_notification), (phonemgr_listener_set_call_notification), (phonemgr_listener_set_cell_notification), (phonemgr_listener_disconnect_cleanup), (phonemgr_listener_thread), (phonemgr_listener_disconnect), (phonemgr_listener_queue_message), (phonemgr_listener_set_time): Add phonemgr_listener_gnokii_func for use in the polling thread, which will mark the connection as terminated, terminate cleanly when the phone is disconnected during an operation. Fix reconnecting using the same PhonemgrListener object * src/app.h: * src/connection.c (attempt_reconnect), (connect_phone), (on_status): Don't try to reconnect if we're not idle (Closes: #495278)
Thanks - works great now.
It doesn't work 100% yet. This is what happended today (with my comments in []): $ ./gnome-phone-manager Gtk-Message: Failed to load module "gnomebreakpad": libgnomebreakpad.so: cannot open shared object file: No such file or directory ** Message: bdaddr 00:19:63:09:1A:08 ** Message: New connection device is 00:19:63:09:1A:08 (changed) ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Connecting... ** Message: Status 1 ** Message: Making serial port connection conn_complete: status 0x00 ** Message: starting search ** Message: Using serial channel 3 for device 00:19:63:09:1A:08 ** (gnome-phone-manager:26125): WARNING **: Failed to load '/usr/local/share/gnome-phone-manager/phones.xml': Failed to open file '/usr/local/share/gnome-phone-manager/phones.xml': No such file or directory ** Message: Model Sony Ericsson K800 using default driver ** Message: Using driver 'AT' ** Message: Status 2 ** Message: Serial port connected ** Message: Connected to device on 00:19:63:09:1A:08 ** Message: Exiting connect thread ** Message: Couldn't get our own phone number ** Message: driver and phone support sms notifications ** Message: emitting network info ** Message: emitting battery ** Message: emitting battery ** Message: driver or phone doesn't support getting the power source ** Message: emitting battery [Walking away with device, but it seems that the device can be partially within bluetooth range.] gnokii I/O error: Transport endpoint is not connected gnokii I/O error: Transport endpoint is not connected ** Message: Status 3 ** Message: Closing serial port connection ** Message: Status 0 ** Message: Disconnect complete ** Message: Auto-retrying the connection ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Connecting... ** Message: Status 1 ** Message: Making serial port connection conn_complete: status 0x04 ** Message: Using serial channel -1 for device 00:19:63:09:1A:08 ** Message: Failed connection to device on 00:19:63:09:1A:08 ** Message: Exiting connect thread conn_complete: status 0x04 [Here I'm back in front of pc and discover that the phone is not connected to g-p-m. Trying to open and close preferences a couple of times to get it to connect, but it doesn't help.] ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Can't connect twice ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Can't connect twice ** Message: New connection device is /dev/ttyS0 (changed) ** Message: Can't connect twice ** Message: New connection device is 00:19:63:09:1A:08 (changed) ** Message: Can't connect twice
Created attachment 113032 [details] [review] More debug Could you gather the debug output again with this patch applied? It would show us why it thinks it's already connected, and would give me something else to go on...
Here you go (why is it using serial channel -1?): $ ./gnome-phone-manager Gtk-Message: Failed to load module "gnomebreakpad": libgnomebreakpad.so: cannot open shared object file: No such file or directory ** Message: bdaddr 00:19:63:09:1A:08 ** Message: New connection device is 00:19:63:09:1A:08 (changed) ** Message: in connect_phone ** Message: is connected: false ** Message: is connecting: false ** Message: status: 0 ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Connecting... ** Message: Status 1 ** Message: Making serial port connection conn_complete: status 0x00 ** Message: starting search ** Message: Using serial channel 3 for device 00:19:63:09:1A:08 ** (gnome-phone-manager:16869): WARNING **: Failed to load '/usr/local/share/gnome-phone-manager/phones.xml': Failed to open file '/usr/local/share/gnome-phone-manager/phones.xml': No such file or directory ** Message: Model Sony Ericsson K800 using default driver ** Message: Using driver 'AT' ** Message: Status 2 ** Message: Serial port connected ** Message: Couldn't get our own phone number ** Message: Connected to device on 00:19:63:09:1A:08 ** Message: Exiting connect thread ** Message: driver and phone support sms notifications ** Message: emitting network info ** Message: emitting battery [walking away with device] ** Message: driver or phone doesn't support getting the power source ** Message: emitting battery gnokii I/O error: Transport endpoint is not connected gnokii I/O error: Transport endpoint is not connected ** Message: Operation '9' failed with error: Device not ready. ** Message: Status 3 ** Message: Closing serial port connection ** Message: Status 0 ** Message: Disconnect complete ** Message: Auto-retrying the connection ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: in connect_phone ** Message: is connected: false ** Message: is connecting: false ** Message: status: 0 ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Connecting... ** Message: Status 1 ** Message: Making serial port connection conn_complete: status 0x00 ** Message: starting search ** Message: Using serial channel 3 for device 00:19:63:09:1A:08 ** Message: Model Sony Ericsson K800 using default driver ** Message: Using driver 'AT' ** Message: Status 2 ** Message: Serial port connected ** Message: Couldn't get our own phone number ** Message: Connected to device on 00:19:63:09:1A:08 ** Message: Exiting connect thread ** Message: driver and phone support sms notifications ** Message: emitting battery [back again - and it reconnects as it should] [walking away again] ** Message: driver or phone doesn't support getting the power source ** Message: emitting battery gnokii I/O error: Transport endpoint is not connected gnokii I/O error: Transport endpoint is not connected ** Message: Operation '9' failed with error: Device not ready. ** Message: Status 3 ** Message: Closing serial port connection ** Message: Status 0 ** Message: Disconnect complete ** Message: Auto-retrying the connection ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: in connect_phone ** Message: is connected: false ** Message: is connecting: false ** Message: status: 0 ** Message: New connection device is 00:19:63:09:1A:08 (not changed) ** Message: Connecting... ** Message: Status 1 ** Message: Making serial port connection conn_complete: status 0x04 ** Message: Using serial channel -1 for device 00:19:63:09:1A:08 ** Message: Failed connection to device on 00:19:63:09:1A:08 ** Message: Exiting connect thread conn_complete: status 0x04 [back again - won't reconnect]
Seems weird. We only try to reconnect every 20 seconds, did you wait that long at the end of the debug for it to reconnect? If so, could you please use gdb to get a backtrace of the hang? ("gdb attach PID" followed by "thread apply all bt"). The -1 means we couldn't lookup the channel using Bluetooth SDP, and we exit the _connect() function straight away.
Yes, I waited for over 20 seconds. Here is the backtrace: (gdb) thread apply all bt
+ Trace 200852
Hey Bastien, your question from comment #11 has been answered. Thus I don't think that this is a NEEDINFO bug anymore and I'm reopening. Althought the stacktrace looks pretty useless to me since there seems to be no g-p-m lib involved. Per, could you install debug symbols for g-p-m, glib and libebook?
*** Bug 570963 has been marked as a duplicate of this bug. ***
Created attachment 131376 [details] [review] Set status to PHONEMGR_LISTENER_ERROR on connection failure When failure to connect occurred in phonemgr_listener_connect () the app->status was left to PHONEMGR_LISTENER_CONNECTING so the code in attempt_reconnect () and in connect_phone () would not try to connect. This patch adds calls to phonemgr_listener_emit_status (l, PHONEMGR_LISTENER_ERROR); in several places of phonemgr_listener_connect () and adds checks for app->status == PHONEMGR_LISTENER_ERROR in attempt_reconnect () and in connect_phone (); an alternate fix could be not to check app->status at all, because phonemgr_listener_connected (app->listener) == FALSE && app->connecting == FALSE should cover all possible cases when we want it to reconnect.
Good catch. Could you make a patch for the second option? It seems more correct to me...
Created attachment 131440 [details] [review] Set status to PHONEMGR_LISTENER_ERROR on connection failure and simplify related checks Changed patch as suggested, simplifying checks in attempt_reconnect () and in connect_phone (). Make phonemgr_listener_connect () set app->status to PHONEMGR_LISTENER_ERROR on connection failure and change attempt_reconnect () and connect_phone () to only check phonemgr_listener_connected (app->listener) == FALSE && app->connecting == FALSE.
Thanks Daniele! 2009-03-26 Bastien Nocera <hadess@hadess.net> * libgsm/phonemgr-listener.c (phonemgr_listener_connect): * src/connection.c (attempt_reconnect), (connect_phone): Patch from Daniele Forsi <dforsi@gmail.com> to really fix reconnecting when a connection fails. Otherwise devices that go out of range will never be reconnected to (Closes: #495278)
*** Bug 572969 has been marked as a duplicate of this bug. ***
*** Bug 579918 has been marked as a duplicate of this bug. ***
This bug has been marked as resolved, yet I am still seeing the behaviour that I reported in Feb 2008 in the following bug report: http://bugzilla.gnome.org/show_bug.cgi?id=572969 (this is marked as a duplicate of this bug above) As I mentioned then, gpm does not reconnect to my phone when it goes out of range. At the moment, I have v0.65 installed under Fedora 11.
To be more accurate: "gpm does not reconnect to my phone when it goes out of range" --> gpm does not reconnect to my phone after losing the connection IIRC, this did work once in an earlier version.
That would be because that patch isn't in 0.65... That's the patch: http://git.gnome.org/cgit/phonemgr/commit/?id=667f48bb113385f2a5815a23bc00cea475a9b24e
*** Bug 642327 has been marked as a duplicate of this bug. ***