tests: make the telnet server shut down a socket gracefully
- test 1452 failed occasionally with ECONNRESET errnos in curl when the server closed the connection in an unclean state. Closes #10509
This commit is contained in:
Родитель
87ed650d04
Коммит
79d0b3c0c0
|
@ -29,7 +29,9 @@ from __future__ import (absolute_import, division, print_function,
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
from util import ClosingFileHandler
|
||||
|
||||
|
@ -90,7 +92,7 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
|||
neg.send_wont("NAWS")
|
||||
|
||||
# Get the data passed through the negotiator
|
||||
data = neg.recv(1024)
|
||||
data = neg.recv(4*1024)
|
||||
log.debug("Incoming data: %r", data)
|
||||
|
||||
if VERIFIED_REQ.encode('utf-8') in data:
|
||||
|
@ -109,6 +111,12 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
|||
log.debug("Sending %r", response_data)
|
||||
self.request.sendall(response_data)
|
||||
|
||||
# put some effort into making a clean socket shutdown
|
||||
# that does not give the client ECONNRESET
|
||||
self.request.settimeout(0.1)
|
||||
self.request.recv(4*1024)
|
||||
self.request.shutdown(socket.SHUT_RDWR)
|
||||
|
||||
except IOError:
|
||||
log.exception("IOError hit during request")
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче