[Q][LONG] using IPC::Shareable to cache data, Apache doesnt start

2002-10-03 Thread Juan Natera

Hello everyone,

I am trying to use a IPC::Shareable tied hash to cache some data at the 
start of apache from my startup.pl script.

this is my startup.pl

-
$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/ or
die GATEWAY_INTERFACE not Perl!;

use Apache::Registry;
use Apache::DBI;
use IPC::Shareable;
use GXV::Abonados;
use strict;

my %GLOBALDATA;
my %options = (
 create= 1,
 exclusive = 0,
 mode  = 0666,
 destroy   = 1,
);

tie %GLOBALDATA, 'IPC::Shareable', 'GLUE', { %options } ||
die tie failed\n;

my $gxv = GXV::Abonados-new ||
die not able to connect to GXV\n;

eval {
 %GLOBALDATA = $gxv-paquetes_shared;
};

die Global data is not accessible: $ if ($);
1;
--


The method GXV::Abonados::paquetes_shared() works, I have tried many 
forms of recieving (and returning of course) the data (a flat scalar, 
arrays, hashes).

If I asign to *GLOBALDATA a short string or number it works, I checked 
IPC::Shareable::SHM_BUFSIZ(); and it's more than enough to hold the 
return value of $gxv-paquetes_shared;

The worst of all is that Apache simply doesnt start, and I get no error 
message at all.

Can someone please give me some insight?

TIA,

Best Regards,

Juan Jose Natera




Re: [Q][LONG] using IPC::Shareable to cache data, Apache doesnt start

2002-10-03 Thread Perrin Harkins

Juan Natera wrote:
 The worst of all is that Apache simply doesnt start, and I get no error 
 message at all.

The error might be on the console, or you could try capturing it and 
writing it to a file.  However, I suggest you ditch IPC::Shareable since 
it's dog slow.  Use MLDBM::Sync, Cache::FileCache, IPC::MM, or Cache::Mmap.

- Perrin




IPC::Shareable

2001-10-16 Thread Rasoul Hajikhani

Pardon the off topic thread,
I am trying to make IPC::Shareable work with my script, however I get
this error:
IPC::Shareable::SharedMem: shmget: Permission denied
 at /usr/local/lib/perl5/site_perl/5.005/IPC/Shareable.pm line 456
[Tue Oct 16 14:44:15 2001] [error] Could not create shared memory
segment: Permission denied
Does any one know what's up?

Here is how I am using it to set:

unless (defined(%WEBACCESS)  tied(%WEBACCESS))
{
die Could not bind shared memory: $! unless
tie %WEBACCESS, 'IPC::Shareable', 'randh_webaccess', {create =1, mode
= 0666};  }

tied(%WEBACCESS)-shlock;

my $user= $WEBACCESS{$code};
unless ($user)
{

 $WEBACCESS{$code}   = {access_level = $status, access =
$entities, time =$time};
}

tied(%WEBACCESS)-shunlock;

And to read it:

tie %WEBACCESS, 'IPC::Shareable', 'randh_webaccess' unless
(defined(%WEBACCESS)  tied(%WEBACCESS));

tied(%WEBACCESS)-shlock;

my $info= $WEBACCESS{$user};

tied(%WEBACCESS)-shunlock;

Any help will be greatly appreciated.
Thanks
-r



[OT] Re: IPC::Shareable

2001-10-16 Thread Stephen Adkins

Hi,

The shared memory segment was already created by another user,
and it was created without permissions for you to write to it.

Try the ipcs command to view existing shared memory segments.
Try the ipcrm command to remove an old one.

Stephen

At 03:02 PM 10/16/2001 -0700, Rasoul Hajikhani wrote:
Pardon the off topic thread,
I am trying to make IPC::Shareable work with my script, however I get
this error:
IPC::Shareable::SharedMem: shmget: Permission denied
 at /usr/local/lib/perl5/site_perl/5.005/IPC/Shareable.pm line 456
[Tue Oct 16 14:44:15 2001] [error] Could not create shared memory
segment: Permission denied
Does any one know what's up?





Re: IPC::Shareable

2001-10-16 Thread Luciano Miguel Ferreira Rocha


Make sure that you're not creating a too big shared memory segment and
that you're (apache) running with an uid that is allowed to create
shared memory segments.

From the apache configuration file:
#  . On HPUX you may not be able to use shared memory as nobody, and the
#suggested workaround is to create a user www and use that user.
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
#  when the value of (unsigned)Group is above 6; 

hugs
  Luciano Rocha

-- 
Luciano Rocha, [EMAIL PROTECTED]

The trouble with computers is that they do what you tell them, not what
you want.
-- D. Cohen



Re: IPC::Shareable

2001-10-16 Thread Perrin Harkins

 I am trying to make IPC::Shareable work with my script, however I get
 this error:
 IPC::Shareable::SharedMem: shmget: Permission denied
  at /usr/local/lib/perl5/site_perl/5.005/IPC/Shareable.pm line 456
 [Tue Oct 16 14:44:15 2001] [error] Could not create shared memory
 segment: Permission denied
 Does any one know what's up?

In the time it takes you to debug it, you could switch your code to
MLDBM::Sync and forget about all these annoying shared memory issues.  It
would probably be faster too.
- Perrin




Re: IPC::Shareable

2001-10-16 Thread Rasoul Hajikhani

Perrin Harkins wrote:
 
  I am trying to make IPC::Shareable work with my script, however I get
  this error:
  IPC::Shareable::SharedMem: shmget: Permission denied
   at /usr/local/lib/perl5/site_perl/5.005/IPC/Shareable.pm line 456
  [Tue Oct 16 14:44:15 2001] [error] Could not create shared memory
  segment: Permission denied
  Does any one know what's up?
 
 In the time it takes you to debug it, you could switch your code to
 MLDBM::Sync and forget about all these annoying shared memory issues.  It
 would probably be faster too.
 - Perrin

Cool, it is really fast... and very easy to implement... Curious though,
is there a delete method/operation any where? Could not find anything in
the perldoc docs indicating a method like that! Any ideas??
Thanks in advance.
-r



Re: IPC::Shareable

2001-10-16 Thread Perrin Harkins

 is there a delete method/operation any where? Could not find anything
in
 the perldoc docs indicating a method like that!

It supports the same interface as normal hashes, so you can delete keys
in the same way.  You may also want to read the MLDBM documentation if
you haven't already.
- Perrin




Shared cache with IPC::Shareable

2001-09-19 Thread Mark Maunder

Hi all,

I'm sharing memory between httpd processes using IPC::Shareable. It is working
but seems to behave inconsistently (memory is often not being freed etc..). I'm
using it for creating common cached areas for file and database contents shared
between httpd children. Is there a better way to do this i.e. Am I stuck with
IPC::Shareable? I'm running mod_perl and the whole application is running as a
single content handler.

It also isn't as fast as I thought it would be  - sure it takes a long time to
do the initial load of all caches on the first request, but I just thought it
would be a little faster than it is. Are there any performance issues I should
be aware of with IPC::Shareable or shared mem in general?

Thanks!

~mark






Re: Shared cache with IPC::Shareable

2001-09-19 Thread Olivier Poitrey

You should try Apache::Cache, it's under developpement but seem to be
stable.

For a real documentation look at the CVS version, the actual release is
poorelly
documented.

http://www.rhapsodyk.net/cgi-bin/cvsweb/Apache-Cache/

--
___
 O  l  i  v  i  e  rP  o  i  t  r  e  y

USA disaster support http://www.osdn.com/911.shtml
- Original Message -
From: Mark Maunder [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2001 5:21 PM
Subject: Shared cache with IPC::Shareable


 Hi all,

 I'm sharing memory between httpd processes using IPC::Shareable. It is
working
 but seems to behave inconsistently (memory is often not being freed
etc..). I'm
 using it for creating common cached areas for file and database contents
shared
 between httpd children. Is there a better way to do this i.e. Am I stuck
with
 IPC::Shareable? I'm running mod_perl and the whole application is running
as a
 single content handler.

 It also isn't as fast as I thought it would be  - sure it takes a long
time to
 do the initial load of all caches on the first request, but I just thought
it
 would be a little faster than it is. Are there any performance issues I
should
 be aware of with IPC::Shareable or shared mem in general?

 Thanks!

 ~mark








Re: Shared cache with IPC::Shareable

2001-09-19 Thread Perrin Harkins

 I'm sharing memory between httpd processes using IPC::Shareable. It is
working
 but seems to behave inconsistently (memory is often not being freed
etc..). I'm
 using it for creating common cached areas for file and database contents
shared
 between httpd children. Is there a better way to do this i.e. Am I stuck
with
 IPC::Shareable? I'm running mod_perl and the whole application is running
as a
 single content handler.

 It also isn't as fast as I thought it would be  - sure it takes a long
time to
 do the initial load of all caches on the first request, but I just thought
it
 would be a little faster than it is. Are there any performance issues I
should
 be aware of with IPC::Shareable or shared mem in general?

Yes, shared memory can be pretty slow.  You should look at Cache::Cache
(specifically the file cache) or MLDBM::Sync.
- Perrin




Re: IPC::Shareable, or, it's supposed to SHARE it, not make more!

2001-09-01 Thread Joe Schaefer

Rob Bloodgood [EMAIL PROTECTED] writes:

 The code in expire_old_accounts is creating a new tied ARRAYREF instead of
 replacing the value of the hash key on this line:
 
 $ACCOUNTS{'QUEUE'} = [@accounts]; #also tried \@accounts;
 
 This didn't happen w/ IPC::Shareable 0.52.  But 0.6 is apparently very
 different, and I can't make the code look like it wants, so the new
 reference is a replacement, not an autovivication.
 

Sorry, but I think you're SOL with IPC::Shareable.  Use something else
instead- I like BerkeleyDB for things like this, but you'll have to 
serialize/stringify your hash values first.

-- 
Joe Schaefer




IPC::Shareable, or, it's supposed to SHARE it, not make more!

2001-08-31 Thread Rob Bloodgood

So, once upon a time, I bought the Eagle and realized I had purchased a
small slice of heaven.

One of the shiny golden nuggets I received from said slice was a shared
memory cache.  It was simple, it was elegant, it was perfect.  It was also
based on IPC::Shareable.  GREAT idea.  BAD juju.

The code in expire_old_accounts is creating a new tied ARRAYREF instead of
replacing the value of the hash key on this line:

$ACCOUNTS{'QUEUE'} = [@accounts]; #also tried \@accounts;

This didn't happen w/ IPC::Shareable 0.52.  But 0.6 is apparently very
different, and I can't make the code look like it wants, so the new
reference is a replacement, not an autovivication.

HELP!

My code follows:

use vars qw/%ACCOUNTS/;

sub handler {

...
# bind accounts structure to shared memory
bind_accounts() unless defined(%ACCOUNTS)  tied(%ACCOUNTS);

my $accountinfo = lookup_account($account)
  or $r-log_reason(no such account: $account), return
HTTP_NO_CONTENT;

}

# Bind the account variables to shared memory using IPC::Shareable
sub bind_accounts {
warn bind_accounts: Binding shared memory if $debug;

unless (tied(%ACCOUNTS)) {
tie (%ACCOUNTS,
 'IPC::Shareable',
 SIGNATURE,
 { create = 1,
   destroy = 0,
   mode = 0666,
 }
) or die Couldn't bind shared memory: $!\n;
}
warn bind_accounts: done if $debug;
}

# bring the current session to the front and
# get rid of any that haven't been used recently
sub expire_old_accounts {
my $id = shift;
warn expire_old_accounts: entered\n if $debug;

tied(%ACCOUNTS)-shlock;
my @accounts = grep($id ne $_, @{$ACCOUNTS{'QUEUE'}});
unshift @accounts, $id;
if (@accounts  MAX_ACCOUNTS) {
my $to_delete = pop @accounts;
delete $ACCOUNTS{$to_delete};
}
$ACCOUNTS{'QUEUE'} = [@accounts]; #also tried \@accounts;
tied(%ACCOUNTS)-shunlock;

warn expire_old_accounts: done\n if $debug;
}


sub lookup_account {
   my $id = shift;

   warn lookup_account: begin if $debug;
   expire_old_accounts($id);

   warn lookup_account: Accessing \$ACCOUNTS{$id} if $debug;
   my $s = $ACCOUNTS{$id};

   if ($s and @{$s-{cat}}) {
   # SUCCESSFUL CACHE HIT
   warn lookup_account: Retrieved accountinfo from Cache (bypassing
SQL) if $debug;
   warn Data::Dumper-Dump([$s],[qw/s/]) if $debug;
   return $s;
   }

   ## NOT IN CACHE... refreshing.

   warn lookup_account: preparing SQL if $debug;

# ... look up some data here.  store in $s

   warn lookup_account: locking shared mem if $debug;
   tied(%ACCOUNTS)-shlock;
   warn lookup_account: assigning \$s to shared mem if $debug;
   $ACCOUNTS{$id} = $s;
   warn Just stored a value, Data::Dumper-Dump([$ACCOUNTS{$id}],[qw/s/])
if $debug;
   warn lookup_account: unlocking shared mem if $debug;
   tied(%ACCOUNTS)-shunlock;

   return $s;

}


TIA!

L8r,
Rob




Re: IPC::Shareable, or, it's supposed to SHARE it, not make more!

2001-08-31 Thread Perrin Harkins

 One of the shiny golden nuggets I received from said slice was a shared
 memory cache.  It was simple, it was elegant, it was perfect.  It was also
 based on IPC::Shareable.  GREAT idea.  BAD juju.

Just use Cache::Cache.  It's faster and easier.
- Perrin




Re: IPC::Shareable (was Re: Perl module - LWP)

2000-10-23 Thread Alexander Farber (EED)

On Sun, 22 Oct 2000, Steven Cotton wrote:
 What version of Perl are you using? I had some problems with make test,
 one of the tests doesn't return and I got a few munged shared memory
 segment errors, I was attempting to install under Solaris 7 and Perl
 5.6.0.

The messages about "munged shared memory" seem to be going if you change

my($tag, $ice) = unpack 'A14 A*' = $stuff;

in the file lib/IPC/Shareable.pm, sub _thaw to the:

my($tag, $ice) = unpack 'A13 A*' = $stuff;

(since the sub _freeze calls

my $stuff = 'IPC::Shareable' . $ice;   

- i.e. 13 chars). But there are further problems ("make test" hangs)...



Re: IPC::Shareable (was Re: Perl module - LWP)

2000-10-23 Thread Alexander Farber (EED)

my $stuff = 'IPC::Shareable' . $ice;   
 - i.e. 13 chars)

Oops, sorry - I can't count on mondays!



Re: IPC::Shareable (was Re: Perl module - LWP)

2000-10-22 Thread Steven Cotton

On Sat, 21 Oct 2000, Alexander Farber (EED) wrote:

 Is anybody successfully using it under Solaris or OpenBSD?
 "make test" hangs for me on these platforms and the module
 author is unreachable :-(

What version of Perl are you using? I had some problems with make test,
one of the tests doesn't return and I got a few munged shared memory
segment errors, I was attempting to install under Solaris 7 and Perl
5.6.0.

 If not IPC::Shareable, what module do you use for fast
 communication between Apache-children?

I started with IPC::SharedCache since it did most of what I wanted, but
took Sam Tregars advice and went with IPC::ShareLite (and serialised all
data myself with Storables freeze  thaw methods) and it works a dream.
One thing I couldn't seem to do was delete() tied IPC::Shareable hash
elements without getting the aforementioned "munged shared memory segment"
errors, which I can do with IPC::ShareLite.

-- 
steven




IPC::Shareable (was Re: Perl module - LWP)

2000-10-21 Thread Alexander Farber (EED)

"David M. Davisson" wrote:
 Yes, it works fine.  No mods.

 From: "David Jourard" [EMAIL PROTECTED]
  Has anyone worked with the LWP module under mod_perl and have they found
  that it works with no modification.

I would like to ask the same question about IPC::Shareable.

Is anybody successfully using it under Solaris or OpenBSD?
"make test" hangs for me on these platforms and the module
author is unreachable :-(

http://vorpal.mcs.drexel.edu/bsd-ports/helix/shared-memory.html
doesn't seem to help on OpenBSD (increasing SHMMAXPGS up to 4096)

If not IPC::Shareable, what module do you use for fast
communication between Apache-children?



Re: IPC::Shareable (was Re: Perl module - LWP)

2000-10-21 Thread Greg Cope

"Alexander Farber (EED)" wrote:
 
 "David M. Davisson" wrote:
  Yes, it works fine.  No mods.
 
  From: "David Jourard" [EMAIL PROTECTED]
   Has anyone worked with the LWP module under mod_perl and have they found
   that it works with no modification.
 
 I would like to ask the same question about IPC::Shareable.
 
 Is anybody successfully using it under Solaris or OpenBSD?
 "make test" hangs for me on these platforms and the module
 author is unreachable :-(
 
 http://vorpal.mcs.drexel.edu/bsd-ports/helix/shared-memory.html
 doesn't seem to help on OpenBSD (increasing SHMMAXPGS up to 4096)
 
 If not IPC::Shareable, what module do you use for fast
 communication between Apache-children?

IPC::ShareLite is writen in C (and hence faster (arguably)), but it does
not serial data structures, so either Freeze / Thaw or DataDumper are
you friends here.

I've seen IPC::Sharable working ok on Solaris 2.6 but cannot offer any
guideance as to why it may not work.

Greg



Amount of memory available to IPC::Shareable?

2000-10-12 Thread Alexander Farber (EED)

I would like to write a small web chat using IPC::Shareable.

How do I find out, how much shared memory is available on some
host, esp. under Solaris and OpenBSD? I have looked at "perldoc
IPC::Shareable" and the outputs of "dmesg", "ipcs -a" and
"ulimit -a" but don't see it yet.

Also, does anyone care to share his/her sources for a mod_perl 
based web-chat (modertion option would be great)? Thank you!



RE: Amount of memory available to IPC::Shareable?

2000-10-12 Thread ricarDo oliveiRa

Hi there,

this may be of some interest to you:
http://perlchat.sourceforge.net/

--Original Message--
From: "Alexander Farber (EED)" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: October 12, 2000 9:21:58 AM GMT
Subject: Amount of memory available to IPC::Shareable?


I would like to write a small web chat using IPC::Shareable.

How do I find out, how much shared memory is available on some
host, esp. under Solaris and OpenBSD? I have looked at "perldoc
IPC::Shareable" and the outputs of "dmesg", "ipcs -a" and
"ulimit -a" but don't see it yet.

Also, does anyone care to share his/her sources for a mod_perl 
based web-chat (modertion option would be great)? Thank you!

--
./ricarDo oliveiRa
__
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup



Re: Amount of memory available to IPC::Shareable?

2000-10-12 Thread Eivind Trondsen

ricarDo oliveiRa [EMAIL PROTECTED] writes:

 Hi there,
 
 this may be of some interest to you:
 http://perlchat.sourceforge.net/
 
 --Original Message--
 From: "Alexander Farber (EED)" [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: October 12, 2000 9:21:58 AM GMT
 Subject: Amount of memory available to IPC::Shareable?
 
 
 I would like to write a small web chat using IPC::Shareable.
 
 How do I find out, how much shared memory is available on some
 host, esp. under Solaris and OpenBSD? I have looked at "perldoc
 IPC::Shareable" and the outputs of "dmesg", "ipcs -a" and
 "ulimit -a" but don't see it yet.

On Linux, you get the interesting stuff by doing

$ ipcs -lm


-- 
-- Eivind Trondsenhttp://www.allycards.com 
-- UberGeekgsm://+4797044324



IPC::Shareable problems

2000-09-06 Thread Steven Cotton

Hi,

I've been having some problems delete()'ing elements from a tied
IPC::Shareable hash. The example from the pod works fine (but that's not
running under mod_perl) so I'm wondering if there are any lifetime/scope
issues with using IPC::Shareable 0.51 under mod_perl 1.24. Has anyone had
any "Munged shared memory segment (size exceeded?)" errors when trying to
access (I'm using `exists()') a previously deleted hash element? I see no
examples in the Eagle of deleting tied and shared hash elements (only
under Apache::Registry), and Deja and various newsgroups and web searches
haven't turned up anything. I'm running Apache 1.3.12 and Perl 5.6.0.

Thanks,

-- 
Steven Cotton
[EMAIL PROTECTED]




Re: IPC::Shareable problems

2000-09-06 Thread Nouguier

Steven Cotton wrote:

 Hi,

 I've been having some problems delete()'ing elements from a tied
 IPC::Shareable hash. The example from the pod works fine (but that's not
 running under mod_perl) so I'm wondering if there are any lifetime/scope
 issues with using IPC::Shareable 0.51 under mod_perl 1.24. Has anyone had
 any "Munged shared memory segment (size exceeded?)" errors when trying to
 access (I'm using `exists()') a previously deleted hash element? I see no
 examples in the Eagle of deleting tied and shared hash elements (only
 under Apache::Registry), and Deja and various newsgroups and web searches
 haven't turned up anything. I'm running Apache 1.3.12 and Perl 5.6.0.

 Thanks,

 --
 Steven Cotton
 [EMAIL PROTECTED]

hi,
 you should try with IPC::ShareLite which provide the same things but seems
better maintained...





Apache::SpeedLimit and problems with IPC::Shareable

1999-11-10 Thread Christian Gilmore

I inserted Apache::SpeedLimit into one of our servers the other day. It works
as advertised, but I'm now seeing errors in the error_log that are coming from
Apache::SpeedLimit/IPC::Shareable. I wonder if anyone else has had this
problem.

From the error_log:

  [Wed Nov 10 13:28:55 1999] [notice] Apache/1.3.9 (Unix)
  mod_perl/1.21 mod_ssl/2.4.2 OpenSSL/0.9.4 configured
  -- resuming normal operations
  [Wed Nov 10 13:28:55 1999] [notice] suEXEC mechanism
  enabled (wrapper: /www/www/apache/bin/suexec)
  panic: restartop
  panic: POPSTACK
  Callback called exit.
  panic: restartop
  panic: POPSTACK
  Callback called exit.
  panic: restartop
  panic: POPSTACK
  Callback called exit.
  panic: restartop
  panic: POPSTACK
  Callback called exit.
  panic: restartop
  panic: POPSTACK
  Callback called exit.
  [Wed Nov 10 13:29:14 1999] [notice] caught SIGTERM,
  shutting down

My software/hardware setup:

  IRIX64 akalice 6.5 11051732 IP25
  mod_perl-1.21
  apache-1.3.9
  Apache::SpeedLimit direct from the "Apache Modules" book

My apache configuration:

  Location /
  PerlAccessHandler  Apache::SpeedLimit
  PerlSetVar SpeedLimit  61
  PerlSetVar SpeedSamples20
  PerlSetVar SpeedForgive10
  /Location

Output from ipcs:

  [akalice:www] /_ ipcs -mbcopt
  IPC status from /dev/kmem as of Wed Nov 10 13:42:19 1999
  T ID KEYMODE   OWNERGROUP  CREATOR
  CGROUP NATTCH SEGSZ   CPID  LPID   ATIMEDTIMECTIME
  Shared Memory:
  m  0 0x53637444 --rw-r--r-- root root root
  root  1  200382   382  9:40:42 no-entry  9:40:42
  m140 0x53504c4d --rw-r--r-- www-nobo www-nobo www-nobo
  www-nobo  0 65536 73426277621049 13:29:07 13:29:07 16:13:46



Any help on this would be appreciated.

Regards,
Christian

-
Christian Gilmore
Senior Technical Staff Member
ATT Labs IP Technology, Florham Park
[EMAIL PROTECTED]
http://www.research.att.com/info/cgilmore