couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [07/19] mochiweb commit: updated refs/heads/upstream to bd6ae7c
Date Wed, 09 Sep 2015 08:42:50 GMT
apply feedback on starting the clock


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

Branch: refs/heads/upstream
Commit: 5f4901d331214b3c875e93cf22abff71868708ec
Parents: 5c48f09
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Thu Jul 30 00:59:35 2015 +0200
Committer: Robert Kowalski <rok@kowalski.gd>
Committed: Thu Jul 30 01:07:59 2015 +0200

----------------------------------------------------------------------
 src/mochiweb_http.erl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/5f4901d3/src/mochiweb_http.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_http.erl b/src/mochiweb_http.erl
index a1e909d..a10c117 100644
--- a/src/mochiweb_http.erl
+++ b/src/mochiweb_http.erl
@@ -67,13 +67,21 @@ stop(Name) ->
 %%      The proplist is as follows: [{name, Name}, {port, Port}, {active_sockets, ActiveSockets},
{timing, Timing}].
 %% @end
 start(Options) ->
-    {ok, _Pid} = mochiweb_clock:start(),
+    ok = ensure_started(mochiweb_clock),
     mochiweb_socket_server:start(parse_options(Options)).
 
 start_link(Options) ->
-    {ok, _Pid} = mochiweb_clock:start_link(),
+    ok = ensure_started(mochiweb_clock),
     mochiweb_socket_server:start_link(parse_options(Options)).
 
+ensure_started(M) ->
+    case erlang:apply(M, start, []) of
+        {ok, _Pid} ->
+            ok;
+        {error, {already_started, _PID}} ->
+            ok
+    end.
+
 loop(Socket, Opts, Body) ->
     ok = mochiweb_socket:exit_if_closed(mochiweb_socket:setopts(Socket, [{packet, http}])),
     request(Socket, Opts, Body).


Mime
View raw message