Revert ipc.py socket opts handling

This commit is contained in:
Florian Bruhin 2017-09-18 14:09:20 +02:00
parent a17c4767d6
commit 01da144a03

View File

@ -139,6 +139,8 @@ class IPCServer(QObject):
_server: A QLocalServer to accept new connections. _server: A QLocalServer to accept new connections.
_socket: The QLocalSocket we're currently connected to. _socket: The QLocalSocket we're currently connected to.
_socketname: The socketname to use. _socketname: The socketname to use.
_socketopts_ok: Set if using setSocketOptions is working with this
OS/Qt version.
_atime_timer: Timer to update the atime of the socket regularly. _atime_timer: Timer to update the atime of the socket regularly.
Signals: Signals:
@ -180,6 +182,14 @@ class IPCServer(QObject):
self._socket = None self._socket = None
self._old_socket = None self._old_socket = None
self._socketopts_ok = os.name == 'nt'
if self._socketopts_ok: # pragma: no cover
# If we use setSocketOptions on Unix with Qt < 5.4, we get a
# NameError while listening...
log.ipc.debug("Calling setSocketOptions")
self._server.setSocketOptions(QLocalServer.UserAccessOption)
else: # pragma: no cover
log.ipc.debug("Not calling setSocketOptions")
def _remove_server(self): def _remove_server(self):
"""Remove an existing server.""" """Remove an existing server."""
@ -200,21 +210,22 @@ class IPCServer(QObject):
raise AddressInUseError(self._server) raise AddressInUseError(self._server)
else: else:
raise ListenError(self._server) raise ListenError(self._server)
if not self._socketopts_ok: # pragma: no cover
# If we use setSocketOptions on Unix with Qt < 5.4, we get a NameError # If we use setSocketOptions on Unix with Qt < 5.4, we get a
# while listening. (see b135569d5c6e68c735ea83f42e4baf51f7972281) # NameError while listening.
# # (see b135569d5c6e68c735ea83f42e4baf51f7972281)
# Also, we don't get an AddressInUseError with Qt 5.5: #
# https://bugreports.qt.io/browse/QTBUG-48635 # Also, we don't get an AddressInUseError with Qt 5.5:
# # https://bugreports.qt.io/browse/QTBUG-48635
# This means we don't use it at all. #
try: # This means we only use setSocketOption on Windows...
os.chmod(self._server.fullServerName(), 0o700) try:
except FileNotFoundError: os.chmod(self._server.fullServerName(), 0o700)
# https://github.com/qutebrowser/qutebrowser/issues/1530 except FileNotFoundError:
# The server doesn't actually exist even if ok was reported as # https://github.com/qutebrowser/qutebrowser/issues/1530
# True, so report this as an error. # The server doesn't actually exist even if ok was reported as
raise ListenError(self._server) # True, so report this as an error.
raise ListenError(self._server)
@pyqtSlot('QLocalSocket::LocalSocketError') @pyqtSlot('QLocalSocket::LocalSocketError')
def on_error(self, err): def on_error(self, err):