Cleanup of old attributes. And addition of "top_tool" which is necessary for -clean...
[PsN.git] / lib / moshog_client_subs.pm
blob07fb42b7f3e95a2693009273734c26ba99a909e2
1 start include statements
2 my $prefix = '/var/lib/moshog';
3 my $request_directory = "$prefix/requests";
4 my $grant_directory = "$prefix";
5 end include statements
7 start new
8 end new
10 start request
12 my $start_threads = $self -> {'start_threads'} ;
13 my $granted_threads = $self -> {'granted_threads'} ;
15 if( -e "$request_directory/$$" ){
16 unlink( "$request_directory/$$" );
19 if( open( REQUEST, '>moshog_request' ) ){
20 #flock( REQUEST, 2 ); # 2 is FLOCK_EX
21 print( REQUEST "S:$start_threads R:$request\n" );
22 #flock( REQUEST, 8 ); # 8 is FLOCK_UN
23 close( REQUEST );
24 system( 'ln -s `pwd`/moshog_request ' . "$request_directory/$$" );
27 # This is a pipe open, therefore we will have an alarm set to
28 # revive us if no-one is listening (ie moshog is dead)
30 # eval {
31 # $SIG{ALRM} = sub { die };
32 # alarm(60);
33 # open( WAKEUP, ">$grant_directory/wakeup" );
34 # print WAKEUP "junk\n";
35 # close( WAKEUP );
36 # alarm(0);
37 # };
39 $self -> {'last_request'} = $request;
41 end request
43 start granted
45 $grant = 0;
46 # eval {
47 # $SIG{ALRM} = sub { die };
48 # alarm(60);
49 if( -e "$grant_directory/$$" ){
50 if( open( GRANT, "<$grant_directory/$$" ) ){
51 my @grant_arr = <GRANT>;
52 close( GRANT );
53 $grant = $grant_arr[0];
54 chomp($grant);
55 # alarm(0);
56 $self -> {'granted_threads'} = $grant;
59 # };
61 end granted