Don't crash of a socket is closed server side

If for some reason, the programmer decides to close the socket server side,
the return value for setopts on the socket is {error, einval} rather than
{error, closed}. This change accepts that and suppresses the error message
generated.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/0f543eda
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/0f543eda
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/0f543eda

Branch: refs/heads/upstream
Commit: 0f543eda81bf1e938365f008fda88eb695ab56ce
Parents: c06e08e
Author: Jesse Gumm <g...@sigma-star.com>
Authored: Wed Sep 26 15:19:33 2018 -0500
Committer: Jesse Gumm <g...@sigma-star.com>
Committed: Wed Sep 26 15:20:39 2018 -0500

----------------------------------------------------------------------
 src/mochiweb_socket.erl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/0f543eda/src/mochiweb_socket.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_socket.erl b/src/mochiweb_socket.erl
index 1756b8e..cbce78a 100644
--- a/src/mochiweb_socket.erl
+++ b/src/mochiweb_socket.erl
@@ -144,5 +144,7 @@ type(_) ->
 
 exit_if_closed({error, closed}) ->
     exit(normal);
+exit_if_closed({error, einval}) ->
+    exit(normal);
 exit_if_closed(Res) ->
     Res.

Reply via email to