After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 495278 - g-p-m does not detect when the phone gets disconnected
g-p-m does not detect when the phone gets disconnected
Status: RESOLVED FIXED
Product: gnome-phone-manager
Classification: Other
Component: general
0.30
Other All
: Normal major
: ---
Assigned To: none
none
: 570963 572969 579918 642327 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-11-09 13:12 UTC by Pawel Kot
Modified: 2011-02-17 22:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g-p-m debug output (864 bytes, text/plain)
2008-06-10 20:17 UTC, Per Thomas Jahr
  Details
More debug (643 bytes, patch)
2008-06-19 10:21 UTC, Bastien Nocera
none Details | Review
Set status to PHONEMGR_LISTENER_ERROR on connection failure (2.20 KB, patch)
2009-03-25 20:45 UTC, Daniele Forsi
needs-work Details | Review
Set status to PHONEMGR_LISTENER_ERROR on connection failure and simplify related checks (2.18 KB, patch)
2009-03-26 15:26 UTC, Daniele Forsi
committed Details | Review

Description Pawel Kot 2007-11-09 13:12:12 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.
Comment 1 Bastien Nocera 2007-11-09 13:23:29 UTC
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.
Comment 2 Pawel Kot 2007-11-11 15:25:06 UTC
That's fixed in gnokii CVS. With every driver and every connection type, gnokii should not hang anymore.
Comment 3 Bastien Nocera 2007-11-11 17:23:42 UTC
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.
Comment 4 Pawel Kot 2007-11-11 17:51:26 UTC
GN_ERR_NOTREADY
Comment 5 Per Thomas Jahr 2008-06-10 20:17:57 UTC
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.
Comment 6 Bastien Nocera 2008-06-11 11:56:34 UTC
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)
Comment 7 Per Thomas Jahr 2008-06-12 11:54:14 UTC
Thanks - works great now.
Comment 8 Per Thomas Jahr 2008-06-13 10:06:20 UTC
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
Comment 9 Bastien Nocera 2008-06-19 10:21:17 UTC
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...
Comment 10 Per Thomas Jahr 2008-06-19 11:12:57 UTC
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]
Comment 11 Bastien Nocera 2008-06-19 13:37:13 UTC
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.
Comment 12 Per Thomas Jahr 2008-06-19 14:00:52 UTC
Yes, I waited for over 20 seconds.

Here is the backtrace:

(gdb) thread apply all bt


Comment 13 Tobias Mueller 2009-01-23 01:00:53 UTC
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?
Comment 14 Daniele Forsi 2009-03-25 20:11:08 UTC
*** Bug 570963 has been marked as a duplicate of this bug. ***
Comment 15 Daniele Forsi 2009-03-25 20:45:19 UTC
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.
Comment 16 Bastien Nocera 2009-03-26 14:03:45 UTC
Good catch. Could you make a patch for the second option? It seems more correct to me...
Comment 17 Daniele Forsi 2009-03-26 15:26:06 UTC
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.
Comment 18 Bastien Nocera 2009-03-26 15:49:26 UTC
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)
Comment 19 Daniele Forsi 2009-03-26 18:03:38 UTC
*** Bug 572969 has been marked as a duplicate of this bug. ***
Comment 20 Bastien Nocera 2009-04-23 10:06:14 UTC
*** Bug 579918 has been marked as a duplicate of this bug. ***
Comment 21 Colin Brace 2009-06-20 14:16:42 UTC
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.

Comment 22 Colin Brace 2009-06-20 16:10:26 UTC
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.
Comment 23 Bastien Nocera 2009-06-24 11:19:31 UTC
That would be because that patch isn't in 0.65...

That's the patch:
http://git.gnome.org/cgit/phonemgr/commit/?id=667f48bb113385f2a5815a23bc00cea475a9b24e
Comment 24 Daniele Forsi 2011-02-17 22:54:59 UTC
*** Bug 642327 has been marked as a duplicate of this bug. ***