GithubHelp home page GithubHelp logo

noss / iserve Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 2.0 342 KB

A small http server for erlang.

Home Page: http://frihjul.net/iserve

License: BSD 3-Clause "New" or "Revised" License

Erlang 100.00%

iserve's People

Contributors

noss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

aberke joliny

iserve's Issues

iserve_master process crashes if client tries to add same server twice

I ran into this issue when I had a gen_server module that called iserve:add_server/4 during init. If the module died, it was restarted by the supervisor, then during the call to iserve_master:call_add_server/2, iserve_server_sup:add_server/2 would return {error, {already_started, Pid}} rather than {ok, Pid}, which caused a badmatch in the iserve_master process, killing it.

The following patch fixes the issue:


---
 src/iserve_master.erl |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/iserve_master.erl b/src/iserve_master.erl
index 02872fc..879c6e9 100644
--- a/src/iserve_master.erl
+++ b/src/iserve_master.erl
@@ -51,9 +51,8 @@ code_change(_OldVsn, State, _Extra) ->
 %%% Internal functions

 call_add_server({_Starter, _Port, _Callback, _Context}=Conf, S) ->
-    {ok, Pid} = iserve_server_sup:add_server(S#state.supervisor, Conf),
+    Reply = iserve_server_sup:add_server(S#state.supervisor, Conf),
     %% TODO: Monitor the little bugger
-    Reply = {ok, Pid},
     {reply, Reply, S}.

 call_del_server(Pid, S) ->
-- 
1.6.3.3

iserve_server invalid state after acceptor abnormal exit

Hi,

There is a bug in iserve/src/iserve_server.erl, this bug is also present in http://www.trapexit.org/A_fast_web_server_demonstrating_some_undocumented_Erlang_features article, it happens when the acceptor process (iserve_socket) receives two consecutives abnormal exists (easy to simulate in shell), upon the second exit, the function "handle_info({'EXIT', Pid, _Abnormal}, #state{acceptor=Pid} = State)" won't match and a new acceptor will not be created, silently stopping the service, the following patch solves the problem:

@@ -91,12 +91,12 @@ handle_info({'EXIT', Pid, normal}, #state{acceptor=Pid} = State) ->
 %% The current acceptor has died, wait a little and try again
 handle_info({'EXIT', Pid, _Abnormal}, #state{acceptor=Pid} = State) ->
     timer:sleep(2000),
-    iserve_socket:start_link(State#state.cb_mod, 
+    New_pid = iserve_socket:start_link(State#state.cb_mod, 
                              State#state.cb_data, 
                              self(), 
                              State#state.listen_socket, 
                              State#state.port),
-    {noreply, State};
+    {noreply, State#state{acceptor=New_pid}};

 handle_info(_Info, State) ->
     {noreply, State}.

Alexandre Girao
https://github.com/alexgirao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.