mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix possible race condition when socket.error isn't raised but remote
connection was closed.
This commit is contained in:
parent
4873b41b33
commit
5f5b67da96
@ -19,6 +19,9 @@ import tempfile
|
|||||||
|
|
||||||
from gunicorn import util
|
from gunicorn import util
|
||||||
|
|
||||||
|
class UnexpectedEOF(object):
|
||||||
|
""" exception raised when remote closed the connection """
|
||||||
|
|
||||||
class TeeInput(object):
|
class TeeInput(object):
|
||||||
|
|
||||||
CHUNK_SIZE = util.CHUNK_SIZE
|
CHUNK_SIZE = util.CHUNK_SIZE
|
||||||
@ -163,8 +166,17 @@ class TeeInput(object):
|
|||||||
|
|
||||||
if self.parser.body_eof():
|
if self.parser.body_eof():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not self._is_socket:
|
||||||
|
if self.parser.is_chunked:
|
||||||
|
data = buf2.getvalue()
|
||||||
|
if data.find("\r\n") >= 0:
|
||||||
|
continue
|
||||||
|
raise UnexpectedEOF("remote closed the connection")
|
||||||
|
|
||||||
data = self._sock.recv(length)
|
data = self._sock.recv(length)
|
||||||
|
if not data:
|
||||||
|
self._is_socket = False
|
||||||
buf2.write(data)
|
buf2.write(data)
|
||||||
|
|
||||||
self._finalize()
|
self._finalize()
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import traceback
|
|||||||
|
|
||||||
from gunicorn import http
|
from gunicorn import http
|
||||||
from gunicorn import util
|
from gunicorn import util
|
||||||
|
from gunicorn.http.tee import UnexpectedEOF
|
||||||
|
|
||||||
class Worker(object):
|
class Worker(object):
|
||||||
|
|
||||||
@ -160,6 +160,8 @@ class Worker(object):
|
|||||||
self.log.exception("Error processing request.")
|
self.log.exception("Error processing request.")
|
||||||
else:
|
else:
|
||||||
self.log.warn("Ignoring EPIPE")
|
self.log.warn("Ignoring EPIPE")
|
||||||
|
except UnexpectedShutdown:
|
||||||
|
self.log.exception("remote closed the connection unexpectedly.")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log.exception("Error processing request.")
|
self.log.exception("Error processing request.")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user