Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleaning up socket shutdown

  • Loading branch information...
commit 33f8d12649957da61a57d4d39329f1543eefb48c 1 parent 6e960d9
Kevin Smith authored

Showing 1 changed file with 4 additions and 3 deletions. Show diff stats Hide diff stats

  1. +4 3 src/gen_nb_server.erl
7 src/gen_nb_server.erl
@@ -37,7 +37,7 @@
37 37 -define(SERVER, ?MODULE).
38 38
39 39 -record(state, {cb,
40   - socks=[],
  40 + sock,
41 41 server_state}).
42 42
43 43 %% @hidden
@@ -69,7 +69,7 @@ init([CallbackModule, IpAddr, Port, InitParams]) ->
69 69 {ok, ServerState} ->
70 70 case listen_on(CallbackModule, IpAddr, Port) of
71 71 {ok, Sock} ->
72   - {ok, #state{cb=CallbackModule, socks=[Sock], server_state=ServerState}};
  72 + {ok, #state{cb=CallbackModule, sock=Sock, server_state=ServerState}};
73 73 Error ->
74 74 CallbackModule:terminate(Error, ServerState),
75 75 Error
@@ -128,7 +128,8 @@ handle_info(Info, #state{cb=Callback, server_state=ServerState}=State) ->
128 128 end.
129 129
130 130 %% @hidden
131   -terminate(Reason, #state{cb=Callback, server_state=ServerState}) ->
  131 +terminate(Reason, #state{cb=Callback, sock=Sock, server_state=ServerState}) ->
  132 + gen_tcp:close(Sock),
132 133 Callback:terminate(Reason, ServerState),
133 134 ok.
134 135

0 comments on commit 33f8d12

Please sign in to comment.
Something went wrong with that request. Please try again.