Avoid unnecessary socket exceptions #80

wants to merge 2 commits into

3 participants


When body is empty, do not issue a second gen_tcp:send() because the client may have already closed the socket

Jeremy Hood When body is empty, do not issue a second gen_tcp:send() because the …
…client may have already closed the socket^C
Mochi Media, Inc. member

As Bob said, it's unclear that this is the correct fix for the described problem. Can you send in some production error reports?
Alternatively, you can try writing a test case with emulating such a problem, if the issue is hard to reproduce.

Also, indentation is slightly wrong here. Personally, I wouldn't use 'if' statement at all, and use something like 'orelse' instead.

Thank you.


I would love to have production errors to send you. Unfortunately, mochiweb_request turns all meaningful error messages into the exception 'normal' without even a meaningful stack trace. I've asked for the error messages to be returned in the past and the answer was no. I have been using a modified version of mochiweb_request that returns meaningful error messages and the error is that the socket is closed. The client is closing the socket as soon as it detects that the headers are done and content length is zero. Then mochiweb_request sends the blank body and gets the exception.

I'm just trying to let you guys know that this is an area in which mochiweb_request could stand to be improved. I don't care if you use my patch, write a patch yourselves your own way with the indentation as you want it, or whatever. I have no pride or sentimental attachment to my patch. I'm just trying to help you guys out because, I'm sure, you guys have more pressing matters on your plate, as I know I do. This is the third iteration we're having of this conversation. I've got a patch that works in my copy and I'm moving on to other things.

@etrepum etrepum closed this Jul 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment