Skip to content

Commit

Permalink
Merge pull request #41 from shinken-monitoring/compat_problem
Browse files Browse the repository at this point in the history
Fix: a compatibility problem with previous version.
  • Loading branch information
Seb-Solon committed Nov 19, 2014
2 parents 3b2d135 + 52f33aa commit 05a46a1
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions module/livestatus_client_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import traceback

from shinken.log import logger

from .livestatus_obj import LiveStatus
from .livestatus_response import LiveStatusListResponse
from .livestatus_query_error import LiveStatusQueryError
Expand Down Expand Up @@ -109,15 +110,26 @@ def read_request(self):
if exceptready:
raise Error.client_error
if inputready:
data = self._read()
if data:
self.buffer_list.append(data)
if self._has_query():
self.last_query_time = time.time()
full_request = b''.join(self.buffer_list)
try:
data = self._read()
except Error.ClientLeft:
# very special case : if we already got some data,
if self.buffer_list and self.buffer_list[-1][-1] == '\n':
# then try to consider it as a valid query
self.logger.warn("Have a query not fully terminated but input closed by remote side.. "
"Let's consider this as a valid query and try process it..")
ret = b''.join(self.buffer_list)
del self.buffer_list[:]
return full_request
continue
return ret
raise # otherwise simply let the ClientLeft propagate.

self.buffer_list.append(data)
if self._has_query():
self.last_query_time = time.time()
full_request = b''.join(self.buffer_list)
del self.buffer_list[:]
return full_request
continue
if time.time() > timeout_time:
raise Error.ClientTimeout('Timeout reading full request from client')
timeout_time += self.read_timeout
Expand Down

0 comments on commit 05a46a1

Please sign in to comment.