Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

server_sent_events: end gen_server process if send fails

  • Loading branch information...
commit 2ad166aa24ad3b5ce73f76223fb96e968539842d 1 parent 6c6f62f
@vinoski vinoski authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 examples/src/server_sent_events.erl
View
10 examples/src/server_sent_events.erl
@@ -61,8 +61,14 @@ handle_info({discard, _YawsPid}, State) ->
handle_info(tick, #state{sock=Socket}=State) ->
Time = erlang:localtime(),
Data = yaws_sse:data(httpd_util:rfc1123_date(Time)),
- yaws_sse:send_events(Socket, Data),
- {noreply, State};
+ case yaws_sse:send_events(Socket, Data) of
+ ok ->
+ {noreply, State};
+ {error, closed} ->
+ {stop, normal, State};
+ {error, Reason} ->
+ {stop, Reason, State}
+ end;
handle_info({tcp_closed, _}, State) ->
{stop, normal, State#state{sock=closed}};
handle_info(_Info, State) ->
Please sign in to comment.
Something went wrong with that request. Please try again.