I have a small HTTP server written using gevent that accepts incoming connections and sends back data using a per-connection greenlet. When the (local) client dies server-side writes to the client succeed despite the socket being in the CLOSE_WAIT state:
$ ls -l /proc/21860/fd |grep 22
lrwx------. 1 mathieu mathieu 64 Mar 21 19:55 22 -> socket:[187093]
$ lsof |grep 187093
python 21860 mathieu 22u IPv4 187093 0t0 TCP localhost.localdomain:36072->localhost.localdomain:48908 (CLOSE_WAIT)
Now, I would expect the send method of the socket I created with gevent.socket.socket to fail with an exception but I get none !
def send(socket, data):
sent = socket.send(data)
while sent != len(data):
data = data[sent:]
sent = socket.send(data)
Is my expectation incorrect ? If not, what could be going wrong here ?