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 6 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
39 changes: 36 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,40 @@ def isstring(s):
except NameError:
return isinstance(s, str)

class SilenceableXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):

protocol_version = 'HTTP/1.1'
def _support_http_1_1():
"""Linux kernels 4.15 and older encounter performance issues with HTTP/1.1
This function returns true if the Linux kernel version is greater than the
input or if the platform is not Linux.
"""
# HTTP/1.1 performance issue only detected on Linux
if platform.system() != 'Linux':
return True

release = platform.release().split('.')
jikawa-az marked this conversation as resolved.
Show resolved Hide resolved

major = 4
minor = 15

platform_major = int(release[0])
platform_minor = int(release[1])

if platform_major > major:
jikawa-az marked this conversation as resolved.
Show resolved Hide resolved
return True
elif platform_major < major:
return False

if platform_minor > minor:
return True
elif platform_minor < minor:
return False

return False


class SilenceableXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
if _support_http_1_1:
jikawa-az marked this conversation as resolved.
Show resolved Hide resolved
protocol_version = 'HTTP/1.1'

def log_message(self, format, *args):
if 0:
Expand All @@ -90,7 +122,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