Robert David | 1 Jul 09:01 2008

Session server expiration hook

Hi,

I'm currently playing with a project where I have need to close some
resources when a user's session expires. Unless I've missed something, I
haven't found a good way of doing this.

In the end I added some code to the yaws_session_server to provide a
mechanism for allowing application tidy when a session expires, and I've
attached the changes as a proposed patch. It modifies
yaws_session_server to add an optional pid to the session information.
When the session expires, the pid is sent a message of
{yaws_session_end, Reason}, where Reason is either timeout or normal,
depending on whether the session has expired or was deleted explicitly
via the api. Sending a message to a pid seemed like a better idea than
having a callback function as it keeps the session server decoupled from
application code. The yaws_api is also modified to add a new function to
allow the PID to be specified on cookie creation.

Does this change seem like a good idea, or is there another/better way
of doing session cleanup?

Attachment (session_end_hook.patch): text/x-patch, 4412 bytes
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
(Continue reading)

Claes Wikström | 1 Jul 10:45 2008

Re: Session server expiration hook

Robert David wrote:
> Hi,
> 
> I'm currently playing with a project where I have need to close some
> resources when a user's session expires. Unless I've missed something, I
> haven't found a good way of doing this.
>

Thanks, good suggestion.

I modified the patch to send a different message to CleanupPid. I also
added an entry to the yaws_api man page:

        new_cookie_session(Opaque)
               Create  a new cookie based session, the yaws system will set the
               cookie. The new randomgenerated cookie  is  returned  from  this
               function.  The  Opaque argument will typically contain user data
               such as username and password

        new_cookie_session(Opaque, TTL)
               As above, but allows to set a session specific  time-out  value,
               overriding the system specified time-out value.

        new_cookie_session(Opaque, TTL, CleanupPid)
               As  above,  but  also  sends a message {yaws_session_end, Reason,
               Cookie, Opaque} to the provided CleanuPid where  Reason  can  be
               either  of  timeout  or normal. The Cookie is the HTTP cookie as
               returned by new_session() and the Opaque is  the  user  provided
               Opaque  parameter  to new_session().  The purpose of the feature
               is to cleanup resources assigned to the session.
(Continue reading)

Jilani Khaldi | 9 Jul 08:55 2008
Picon

Using decimal numbers issue

Hi all,
as you can see in this web page:
http://www.jkhaldi.eu/meta/sunlight/sun.html
if I introduce the value of Latitude 42, instead of 42.0, yaws gives me 
an error. I should like it accepts even integer numbers in this case.
What kind of guard do I have to put and where?
This is the code:

<erl>
   kv(K,L) ->
   {value, {K, V}} = lists:keysearch(K,1,L), V.

out(A) ->
   L = yaws_api:parse_post(A),
   Month = list_to_integer(kv("month", L)),
   Day = list_to_integer(kv("day", L)),
   Hour = list_to_integer(kv("hour", L)),
   Min = list_to_integer(kv("min", L)),
   TZ = list_to_integer(kv("tz", L)),
   Lat = list_to_float(kv("lat", L)),
   Long = list_to_float(kv("long", L)),

{Sun1,Sun2,Noon,Alt,Az}=sunposition:calc({Month,Day,Hour,Min,TZ,Lat,Long}),
...
</erl>
Thank you!
--

-- 
Jilani KHALDI
---------------------
http://www.jkhaldi.eu
(Continue reading)

Robert Raschke | 9 Jul 10:30 2008

Re: Using decimal numbers issue

On 7/9/08, Jilani Khaldi <jilani@...> wrote:
> Hi all,
> as you can see in this web page:
> http://www.jkhaldi.eu/meta/sunlight/sun.html
> if I introduce the value of Latitude 42, instead of 42.0, yaws gives me
> an error. I should like it accepts even integer numbers in this case.
> What kind of guard do I have to put and where?
> This is the code:
>
> <erl>
>   kv(K,L) ->
>   {value, {K, V}} = lists:keysearch(K,1,L), V.
>
> out(A) ->
>   L = yaws_api:parse_post(A),
>   Month = list_to_integer(kv("month", L)),
>   Day = list_to_integer(kv("day", L)),
>   Hour = list_to_integer(kv("hour", L)),
>   Min = list_to_integer(kv("min", L)),
>   TZ = list_to_integer(kv("tz", L)),
>   Lat = list_to_float(kv("lat", L)),
>   Long = list_to_float(kv("long", L)),
>
> {Sun1,Sun2,Noon,Alt,Az}=sunposition:calc({Month,Day,Hour,Min,TZ,Lat,Long}),
> ...
> </erl>

You could try something like this:

VLat = kv("lat", L),
(Continue reading)

Mikael Karlsson | 9 Jul 11:06 2008

Re: Using decimal numbers issue

Hi Jilany,
one solution:

my_list_to_float(NumberString) ->
  case string:to_float(NumberString) of 
    {error,no_float} -> float(list_to_integer(NumberString));  %% "42" 
    {Float,_} -> Float                                               %% "42.0"
end.

Wednesday 09 July 2008 08:55:27 Jilani Khaldi wrote:
> Hi all,
> as you can see in this web page:
> http://www.jkhaldi.eu/meta/sunlight/sun.html
> if I introduce the value of Latitude 42, instead of 42.0, yaws gives me
> an error. I should like it accepts even integer numbers in this case.
> What kind of guard do I have to put and where?
> This is the code:
>
> <erl>
>    kv(K,L) ->
>    {value, {K, V}} = lists:keysearch(K,1,L), V.
>
> out(A) ->
>    L = yaws_api:parse_post(A),
>    Month = list_to_integer(kv("month", L)),
>    Day = list_to_integer(kv("day", L)),
>    Hour = list_to_integer(kv("hour", L)),
>    Min = list_to_integer(kv("min", L)),
>    TZ = list_to_integer(kv("tz", L)),
>    Lat = list_to_float(kv("lat", L)),
(Continue reading)

mog | 9 Jul 16:40 2008
Picon

patch for yaws


Hi I ran dialyzer over my erlang dir and found the following errors

yaws_ctl.erl:223: Call to missing or unexported function gen_server:call/4
yaws_dav.erl:512: Call to missing or unexported function
yaws_revproxy:store_chunk_num/2
yaws_dav.erl:518: Call to missing or unexported function
yaws_revproxy:store_chunk/4

Attached is a fix for the first error.  The next two I believe involve
taking old yaws_revproxy code from get_chunk and that those two lines in
yaws_dav where mistyped.  Or I could be completely wrong which is why I
didn't attempt patching them.

Mog
Attachment (yaws_ctl.patch): text/x-patch, 356 bytes
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@...
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Claes Wikström | 9 Jul 18:07 2008

Re: patch for yaws

mog wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi I ran dialyzer over my erlang dir and found the following errors

Thanks -

/klacke

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
John 'fess' Fessenden | 10 Jul 19:00 2008

log_wrap_size = 0 not closing old logs when reopening the access log.


         log_wrap_size = Integer

               If we set the value to 0 the logs will never wrap. If  
we want to
               use Yaws in combination with a more traditional log  
wrapper such
               as logrotate, set the size to 0 and Yaws will  reopen   
the  log-
               files once they have be renamed/removed.

We tried this,  and noticed that the "renamed" logfiles were still  
kept open after the original named file was reopened.  resulting in a  
FD leak.

The fix seems simple: also close the old log in the "Logfile  
disappeared" part of the case statement.

for you consideration, a patch:

Index: yaws_log.erl
===================================================================
--- yaws_log.erl        (revision 3394)
+++ yaws_log.erl        (revision 3395)
 <at>  <at>  -441,6 +441,7  <at>  <at> 
              %% Logfile disapeared,
              error_logger:format("Logfile ~p disapeared - we reopen  
it",
                                  [AL#alog.filename]),
+            file:close(AL#alog.fd),
(Continue reading)

Claes Wikstrom | 11 Jul 15:40 2008

Re: log_wrap_size = 0 not closing old logs when reopening the access log.

John 'fess' Fessenden wrote:

> for you consideration, a patch:
> 
> Index: yaws_log.erl
> ===================================================================
> --- yaws_log.erl        (revision 3394)
> +++ yaws_log.erl        (revision 3395)
>  <at>  <at>  -441,6 +441,7  <at>  <at> 
>               %% Logfile disapeared,
>               error_logger:format("Logfile ~p disapeared - we reopen  
> it",
>                                   [AL#alog.filename]),
> +            file:close(AL#alog.fd),
>               {ok, Fd2} = file:open(AL#alog.filename, [write, raw]),
>               AL#alog{fd = Fd2}
>       end.

Brilliant - applied.

/klacke

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
thomas refis | 14 Jul 15:05 2008
Picon

yaws_api:delete_cookie_session problem

Hi,

I'm currently developing a blog with yaws, and I've got a lot of
issues with the yaws' session system.
It seems that the cookie expiration doesn't match the session
expiration. So yaws often crash 'cause the user still have the cookie
but yaws don't find it in the ETS table.
Reading this mail-list I saw that someone already pointed that out,
but I didn't get so I do it again.
My other problem is that yaws_api:delete_cookie_session doesn't work.
I briefly tried to read but I didn't go far. So I guessed it would be
better (at least easier [for me]) to post here than try to fix it
myself.
I so wonder if someone here know how to fix it, or could tell me what
I do wrong and how to do better.

Thank you.

PS: my english is probably bad (or worse), so I apologiz.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

Gmane