Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions telnetsrv/green.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ def finish(self):

def getc(self, block=True):
"""Return one character from the input queue"""
try:
return self.cookedq.get(block)
except gevent.queue.Empty:
return ''
while True:
try:
return self.cookedq.get(block, timeout = 10)
except gevent.queue.Empty:
if block and not self.eof:
continue
return ''

def inputcooker_socket_ready(self):
"""Indicate that the socket is ready to be read"""
Expand Down
15 changes: 13 additions & 2 deletions telnetsrv/telnetsrvlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,17 @@ def setup(self):
def finish(self):
"End this session"
log.debug("Session disconnected.")
self.sock.shutdown(socket.SHUT_RDWR)
try:
self.sock.shutdown(socket.SHUT_RDWR)
except socket.error as e:
# on some systems shutdown fails with EINVAL.
# http://www.freebsd.org/cgi/query-pr.cgi?pr=31647
import errno
if e.errno == errno.EINVAL:
pass
else:
raise
self.sock.close()
self.session_end()

def session_start(self):
Expand Down Expand Up @@ -665,7 +675,8 @@ def readline(self, echo=None, prompt='', use_history=True):
c = self.ansi_to_curses(c)
if c == theNULL:
continue

elif c == '':
return 'QUIT'
elif c == curses.KEY_LEFT:
if insptr > 0:
insptr = insptr - 1
Expand Down