Merge "Avoid crash due to POLLIN event check"

This commit is contained in:
Zuul 2020-12-02 14:29:33 +00:00 committed by Gerrit Code Review
commit 05d2786986
1 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,7 @@
import json
import logging
import platform
import pprint
import select
import six.moves
@ -34,6 +35,7 @@ UPDATE_ALLOWED_KEYS = ['description', 'submit-type',
'content-merge', 'change-id',
'project-state',
'max-object-size-limit']
IS_LINUX = platform.system() == "Linux"
class GerritConnection(object):
@ -158,10 +160,13 @@ class GerritWatcher(threading.Thread):
ret = poll.poll()
for (fd, event) in ret:
if fd == stdout.channel.fileno():
if event == select.POLLIN:
# event is a bitmask
# On Darwin non-critical OOB messages can be received
if (IS_LINUX and event == select.POLLIN) or \
(not IS_LINUX and event & select.POLLIN):
self._read(stdout)
else:
raise Exception("event on ssh connection")
raise Exception("event %s on ssh connection" % event)
def _consume(self, client):
"""Consumes events using the given client."""