PYTHON-1350 - Work around getsockopt issue on NetBSD
NetBSD doesn't support testing TCP_KEEPIDLE and friends, only setting them.
This commit is contained in:
parent
b00584b892
commit
728ee59f27
@ -1,6 +1,21 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Changes in Version 3.5.1
|
||||
------------------------
|
||||
|
||||
Version 3.5.1 fixes bugs reported since the release of 3.5.0:
|
||||
|
||||
- Work around socket.getsockopt issue with NetBSD.
|
||||
|
||||
Issues Resolved
|
||||
...............
|
||||
|
||||
See the `PyMongo 3.5.1 release notes in JIRA`_ for the list of resolved issues
|
||||
in this release.
|
||||
|
||||
.. _PyMongo 3.5.1 release notes in JIRA: https://jira.mongodb.org/projects/PYTHON/versions/18721
|
||||
|
||||
Changes in Version 3.5
|
||||
----------------------
|
||||
|
||||
|
||||
@ -150,9 +150,15 @@ else:
|
||||
def _set_tcp_option(sock, tcp_option, max_value):
|
||||
if hasattr(socket, tcp_option):
|
||||
sockopt = getattr(socket, tcp_option)
|
||||
default = sock.getsockopt(socket.SOL_TCP, sockopt)
|
||||
if default > max_value:
|
||||
sock.setsockopt(socket.SOL_TCP, sockopt, max_value)
|
||||
try:
|
||||
# PYTHON-1350 - NetBSD doesn't implement getsockopt for
|
||||
# TCP_KEEPIDLE and friends. Don't attempt to set the
|
||||
# values there.
|
||||
default = sock.getsockopt(socket.IPPROTO_TCP, sockopt)
|
||||
if default > max_value:
|
||||
sock.setsockopt(socket.IPPROTO_TCP, sockopt, max_value)
|
||||
except socket.error:
|
||||
pass
|
||||
|
||||
def _set_keepalive_times(sock):
|
||||
_set_tcp_option(sock, 'TCP_KEEPIDLE', _MAX_TCP_KEEPIDLE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user