Prevent Unnecessary Socket Exceptions #79

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@jdhood1

jdhood1 commented Jun 22, 2012

We were seeing a lot of seemingly harmless socket exceptions in our system. After a little digging, I found out that it's because the client is closing the socket as soon as it receives a complete message from mochiweb:respond(). Unfortunately, mochiweb:respond() would then try to send the body, even when it is blank (""), which was causing the exception. This change cleans up those unnecessary exceptions.

We were seeing a lot of seemingly harmless socket exceptions in our s…
…ystem. After a little digging, I found out that it's because the client is closing the socket as soon as it receives a complete message from mochiweb:respond(). Unfortunately, mochiweb:respond() would then try to send the body, even when it is blank (""), which was causing the exception. This change cleans up those unnecessary exceptions.
@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Jun 22, 2012

Member

I'm not so sure that this is the correct fix, it would be helpful to see exactly what the exceptions look like and ideally there would be a test for this.

Member

etrepum commented Jun 22, 2012

I'm not so sure that this is the correct fix, it would be helpful to see exactly what the exceptions look like and ideally there would be a test for this.

@jdhood1

This comment has been minimized.

Show comment
Hide comment
@jdhood1

jdhood1 Jun 25, 2012

Yah, I didn't like having the blank string hard-coded, especially when it's iodata(). Perhaps 'iolist_size(Body) == 0' would be a more appropriate check.

I've been trying all morning to reproduce this problem consistently in a unit test, but I haven't yet. I'll keep trying and send you the unit test, if I finally get it to reproduce the problem.

jdhood1 commented Jun 25, 2012

Yah, I didn't like having the blank string hard-coded, especially when it's iodata(). Perhaps 'iolist_size(Body) == 0' would be a more appropriate check.

I've been trying all morning to reproduce this problem consistently in a unit test, but I haven't yet. I'll keep trying and send you the unit test, if I finally get it to reproduce the problem.

@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Jun 25, 2012

Member

I'd at least like to look at the exception, even if you can't reliably reproduce it.

Member

etrepum commented Jun 25, 2012

I'd at least like to look at the exception, even if you can't reliably reproduce it.

@etrepum

This comment has been minimized.

Show comment
Hide comment
@etrepum

etrepum Jun 25, 2012

Member

Also there's already a call to iolist_size earlier in the function, so you could extract that into a variable to avoid calling it twice (you probably wouldn't be able to do it in a guard anyway)

Member

etrepum commented Jun 25, 2012

Also there's already a call to iolist_size earlier in the function, so you could extract that into a variable to avoid calling it twice (you probably wouldn't be able to do it in a guard anyway)

@doubleyou

This comment has been minimized.

Show comment
Hide comment
@doubleyou

doubleyou Jun 30, 2012

Member

This code won't even work, since for a default value in the 'if' statement you should use 'true', not '_'.

Member

doubleyou commented Jun 30, 2012

This code won't even work, since for a default value in the 'if' statement you should use 'true', not '_'.

@jdhood1

This comment has been minimized.

Show comment
Hide comment
@jdhood1

jdhood1 Jul 2, 2012

You're absolutely right. Clearly, the web interface should only be used by experts. I've submitted another pull request with the correct code change that compiles and passes all unit tests.

jdhood1 commented Jul 2, 2012

You're absolutely right. Clearly, the web interface should only be used by experts. I've submitted another pull request with the correct code change that compiles and passes all unit tests.

@jdhood1 jdhood1 closed this Jul 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment