Merge "Check whether poll is available or not and let eventlet chose the best hub when it isn't."

This commit is contained in:
Jenkins 2013-01-04 21:15:36 +00:00 committed by Gerrit Code Review
commit 6e9b1a52a5
3 changed files with 30 additions and 4 deletions

View File

@ -751,6 +751,31 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
return adapted_logger
def get_hub():
"""
Checks whether poll is available and falls back
on select if it isn't.
Note about epoll:
Review: https://review.openstack.org/#/c/18806/
There was a problem where once out of every 30 quadrillion
connections, a coroutine wouldn't wake up when the client
closed its end. Epoll was not reporting the event or it was
getting swallowed somewhere. Then when that file descriptor
was re-used, eventlet would freak right out because it still
thought it was waiting for activity from it in some other coro.
"""
try:
import select
if hasattr(select, "poll"):
return "poll"
return "selects"
except ImportError:
return None
def drop_privileges(user):
"""
Sets the userid/groupid of the current process, get session leader, etc.

View File

@ -33,7 +33,7 @@ from urllib import unquote
from swift.common.swob import Request
from swift.common.utils import capture_stdio, disable_fallocate, \
drop_privileges, get_logger, NullLogger, config_true_value, \
validate_configuration
validate_configuration, get_hub
def monkey_patch_mimetools():
@ -135,7 +135,8 @@ def run_wsgi(conf_file, app_section, *args, **kwargs):
wsgi.HttpProtocol.log_message = \
lambda s, f, *a: logger.error('ERROR WSGI: ' + f % a)
wsgi.WRITE_TIMEOUT = int(conf.get('client_timeout') or 60)
eventlet.hubs.use_hub('poll')
eventlet.hubs.use_hub(get_hub())
eventlet.patcher.monkey_patch(all=False, socket=True)
eventlet_debug = config_true_value(conf.get('eventlet_debug', 'no'))
eventlet.debug.hub_exceptions(eventlet_debug)

View File

@ -33,13 +33,13 @@ from eventlet.support.greenlets import GreenletExit
from swift.common.ring import Ring
from swift.common.utils import whataremyips, unlink_older_than, lock_path, \
compute_eta, get_logger, write_pickle, renamer, dump_recon_cache, \
rsync_ip, mkdirs, config_true_value, list_from_csv
rsync_ip, mkdirs, config_true_value, list_from_csv, get_hub
from swift.common.bufferedhttp import http_connect
from swift.common.daemon import Daemon
from swift.common.http import HTTP_OK, HTTP_INSUFFICIENT_STORAGE
from swift.common.exceptions import PathNotDir
hubs.use_hub('poll')
hubs.use_hub(get_hub())
PICKLE_PROTOCOL = 2
ONE_WEEK = 604800