Dan Kenigsberg has uploaded a new change for review.
Change subject: betterAsyncore: Fix AttributeError on disconnect
......................................................................
betterAsyncore: Fix AttributeError on disconnect
Recently we added logging when SSLError is raised during recv(), which
happens when a client disconnects in an unclean way. Unfortunately,
logging the error raises an AttributeError and fail to close the
connection as intended:
>> from yajsonrpc.betterAsyncore import Dispatcher
>> d = Dispatcher()
>> d.log.error("message")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'error'
Dispatcher.log is a method, not a logger instance.
This patches adds a "vds.dispatcher" logger and use it to log the
message.
Since this is an expected event, and logging error and warnings is also
duplicated to the system log, we use now info message.
Change-Id: I84387711167de39ea9364f0717f23ba4aa95edf5
Bug-Url:
https://bugzilla.redhat.com/1272496
Backport: 3.6
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
Reviewed-on:
https://gerrit.ovirt.org/47406
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
---
M lib/yajsonrpc/betterAsyncore.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/47421/1
diff --git a/lib/yajsonrpc/betterAsyncore.py b/lib/yajsonrpc/betterAsyncore.py
index 97b301a..3d43ffb 100644
--- a/lib/yajsonrpc/betterAsyncore.py
+++ b/lib/yajsonrpc/betterAsyncore.py
@@ -18,6 +18,7 @@
# while enabling compositing instead of inheritance.
from __future__ import absolute_import
import asyncore
+import logging
import socket
from errno import EWOULDBLOCK
@@ -26,6 +27,8 @@
class Dispatcher(asyncore.dispatcher):
+
+ _log = logging.getLogger("vds.dispatcher")
def __init__(self, impl=None, sock=None, map=None):
# This has to be done before the super initialization because
@@ -118,7 +121,7 @@
else:
raise
except SSL.SSLError as e:
- self.log.error('SSL error during reading data: %s', e)
+ self._log.info('SSL error during recv: %s, closing connection', e)
self.handle_close()
return ''
--
To view, visit
https://gerrit.ovirt.org/47421
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I84387711167de39ea9364f0717f23ba4aa95edf5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>