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 4 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
35 changes: 32 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,36 @@ def isstring(s):
except NameError:
return isinstance(s, str)

class SilenceableXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):

protocol_version = 'HTTP/1.1'
def _check_linux_kernel(major, minor):
"""Small helper version to check if the current Linux kernel is older than
jikawa-az marked this conversation as resolved.
Show resolved Hide resolved
the input version and return true. If not Linux return false.
"""
if platform.system() != 'Linux':
return False

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

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

if platform_major < major:
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):
# Linux kernels 4.15 and older encounter performance issues with HTTP/1.1
if not _check_linux_kernel(4,15):
protocol_version = 'HTTP/1.1'

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

daemon_threads = True
if not _check_linux_kernel(4,15):
daemon_threads = True

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