Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP for kernel < 4.16 #2132

Merged
merged 9 commits into from
Mar 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions tools/rosgraph/src/rosgraph/xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import errno
import logging
import platform
import select
import socket

Expand Down Expand Up @@ -76,9 +77,32 @@ def isstring(s):
except NameError:
return isinstance(s, str)

class SilenceableXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):

protocol_version = 'HTTP/1.1'
def _support_http_1_1():
"""
Determine whether HTTP 1.1 should be enabled for XMLRPC communications.

This will be true on non-Linux systems, and on Linux kernels at least as
new as 4.16. Linux kernels 4.15 and older cause significant performance
degradation in the roscore when using HTTP 1.1
"""
if platform.system() != 'Linux':
return True
minimum_supported_major, minimum_supported_minor = (4, 16)
release = platform.release().split('.')
platform_major = int(release[0])
platform_minor = int(release[1])
if platform_major < minimum_supported_major:
return False
if (platform_major == minimum_supported_major and
platform_minor < minimum_supported_minor):
return False
return True


class SilenceableXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
if _support_http_1_1():
protocol_version = 'HTTP/1.1'

def log_message(self, format, *args):
if 0:
Expand All @@ -90,7 +114,8 @@ class ThreadingXMLRPCServer(socketserver.ThreadingMixIn, SimpleXMLRPCServer):
requests via threading. Also makes logging toggleable.
"""

daemon_threads = True
if _support_http_1_1():
daemon_threads = True

def __init__(self, addr, log_requests=1):
"""
Expand Down