Skip to content

Commit

Permalink
Fix HTTP for kernel < 4.16 (#2132)
Browse files Browse the repository at this point in the history
Addressing performance issues described in #2118

Signed-off-by: Jesse Ikawa <jikawa@amazon.com>

Co-authored-by: Emerson Knapp <537409+emersonknapp@users.noreply.github.com>
  • Loading branch information
jikawa-az and emersonknapp authored Mar 11, 2021
1 parent f8022d7 commit 8b40899
Showing 1 changed file with 28 additions and 3 deletions.
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

0 comments on commit 8b40899

Please sign in to comment.