Permalink
Browse files

Two patches by Joseph Wayen Norton, one dbg-bug and one providing bet…

…ter cookie support for yaws sesssions

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1393 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
klacke committed Feb 17, 2009
1 parent 4cf7977 commit 5f13a9c18e01e62d484c10fa9c121f8e66c09e01
Showing with 46 additions and 9 deletions.
  1. +24 −0 man/yaws.1
  2. +1 −1 src/yaws_server.erl
  3. +21 −8 src/yaws_session_server.erl
View
@@ -173,6 +173,30 @@ that all .yaws files are syntactically correct
.TP
\fB\--version\fR
output version information and exit
+
+.SH ENVIRONMENT VARIABLES
+.TP
+\fBHOME\fR
+Is used to determine where we write the temporary files. By default
+all tmp files end up in $HOME/.yaws. This includes the JIT files
+that are the result of processed .yaws files and also the so called
+control file that is used by the daemon to write the port number
+to which it is listening for control commands such as "yaws --status"
+
+Thus HOME is the handle we use in the control commands to
+find the control file so that we know where to connect to.
+
+.TP
+\fBYAWSHOME\fR
+Can be used to override the HOME variable. This is useful when we
+for example are running yaws under port binding programs such as
+authpriv.
+
+It's useful by distros that don't want Yaws to write any files
+ever in the HOME directory of root.
+
+
+
.SH AUTHOR
Written by Claes Wikstrom
.SH "SEE ALSO"
View
@@ -3379,7 +3379,7 @@ do_url_type(SC, GetPath, ArgDocroot, VirtualDir) ->
case Mount of
[$/] ->
%%'root' appmod
- _PreSegments = [],
+ PreSegments = [],
PostSegments = lists:sublist(RequestSegs,1,
length(RequestSegs)),
Prepath = "";
@@ -18,7 +18,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
-include("../include/yaws_api.hrl").
--export([new_session/1,new_session/2,new_session/3,
+-export([new_session/1,new_session/2,new_session/3,new_session/4,
cookieval_to_opaque/1,
print_sessions/0,
replace_session/2,
@@ -68,8 +68,18 @@ new_session(Opaque, TTL, Cleanup) ->
{new_session, Opaque, TTL, Cleanup}, infinity)
end.
-cookieval_to_opaque(CookieString) ->
- case ets:lookup(?MODULE, CookieString) of
+new_session(Opaque, TTL, Cleanup, Cookie) ->
+ case TTL of
+ undefined ->
+ gen_server:call(?MODULE,
+ {new_session, Opaque, ?TTL, Cleanup, Cookie}, infinity);
+ _ ->
+ gen_server:call(?MODULE,
+ {new_session, Opaque, TTL, Cleanup, Cookie}, infinity)
+ end.
+
+cookieval_to_opaque(Cookie) ->
+ case ets:lookup(?MODULE, Cookie) of
[Y] ->
Y2 = Y#ysession{to = gnow() + Y#ysession.ttl},
ets:insert(?MODULE, Y2),
@@ -167,19 +177,22 @@ seed() ->
%%----------------------------------------------------------------------
-handle_call({new_session, Opaque, TTL, Cleanup}, _From, _State) ->
- Now = gnow(),
+handle_call({new_session, Opaque, TTL, Cleanup}, From, State) ->
N = random:uniform(16#ffffffffffffffff), %% 64 bits
+ Cookie = atom_to_list(node()) ++ [$-|integer_to_list(N)],
+ handle_call({new_session, Opaque, TTL, Cleanup, Cookie}, From, State);
+
+handle_call({new_session, Opaque, TTL, Cleanup, Cookie}, _From, _State) ->
+ Now = gnow(),
TS = calendar:local_time(),
- C = atom_to_list(node()) ++ [$-|integer_to_list(N)],
- NS = #ysession{cookie = C,
+ NS = #ysession{cookie = Cookie,
starttime = TS,
opaque = Opaque,
to = Now + TTL,
ttl = TTL,
cleanup = Cleanup},
ets:insert(?MODULE, NS),
- {reply, C, undefined, to()};
+ {reply, Cookie, undefined, to()};
handle_call(stop, _From, State) ->
{stop, stopped, State}.

0 comments on commit 5f13a9c

Please sign in to comment.