wireless driver failed to connect to port

Bug #1256198 reported by PeterT
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Charles Haley

Bug Description

With calibre's wireless driver set to start automatically and the "Open With" plugin installed, if the "Open With" plugin is used to launch Sigil to edit a book, and calibre is shut down with Sigil still open, any subsequent restarts of calibre with Sigil still open will result in an error

calibre, version 1.12.0
ERROR: Problem starting the wireless device: The wireless device driver did not start. It said "Failed to connect to port 9090. Try a different value.

Using SYsinternals tcpview command shows port 9090 still open with the pid thatcorresponds to what calibre WAS running under, but displays <non-existant> for the process name. (This assumes that tcpview is started after calibre is shutdown. If tcpview is started while calibre is still active, the process name will correctly display calibre.

Shutting Sigil down allows the port to close, and for calibre to restart the wireless driver.

Environment:
Windows 7, 74 bit SP1 plus all current patches
Calibre 1.12.0
Open With plugin: 1.5.7

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1256198

Changing the component for this bug.

 assignee cbhaley
 status triaged

Revision history for this message
Kovid Goyal (kovid) wrote :

@Charles: You probably need to mark the socket as non-inheritable on
creation.

Changed in calibre:
assignee: nobody → Charles Haley (cbhaley)
status: New → Triaged
Revision history for this message
Kovid Goyal (kovid) wrote :

Here is some example code to mark sockets as not inheritable:
https://mail.python.org/pipermail/python-dev/2007-June/073745.html

Ideally one would like to create the socket as non-inheritable to avoid
the race, but there seems to be no way to do that with python 2.x (IIRC
python 3.4 makes all fds non inheritable, but that is obviously useless
for us).

Revision history for this message
Charles Haley (cbhaley) wrote :

Fix committed.

Tested with the open_with plugin on windows.

Tested with the following snippet (calibre-debug -e) on both windows and linux. Not tested on macs.

import socket
from calibre.utils.socket_inheritance import set_socket_inherit
from calibre.utils.socket_inheritance import get_socket_inherit

socket = socket.socket()
print get_socket_inherit(socket)
set_socket_inherit(socket, False)
print get_socket_inherit(socket)
set_socket_inherit(socket, True)
print get_socket_inherit(socket)

FWIW: the code provided in that link is wrong. It inverted the sense of the inherit flag on windows.

Changed in calibre:
status: Triaged → Fix Committed
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.