Re: dont understand mem-mapping

2001-11-12 Thread Stas Bekman

Peter Pilsl wrote:

 I just cant get the following in my brain.  I have a modules that is
 started with apache using the PerlModule-directive in httpd.conf.
 
 This module defines a global pointer on startup that should be the
 same in all sub-instances of httpd and really in the current
 apache-session all instances print out : $g_ptr : HASH(0x8458a30)
 
 This hashpointer is later filled with different values (dbhandles,
 filehandles ...) that should kept open over more calls.
 
 Now each session has the same pointer, but the content of the
 anonymous hash its pointing too is different in each instance !!
 
 thread 1:
 $g_ptr : HASH(0x8458a30)
 $g_ptr-{counter} : SCALAR(0x85aa62c)
 
 thread 2:
 $g_ptr : HASH(0x8458a30)
 $g_ptr-{counter} : SCALAR(0x85f5e2c)
 
 A even more strange example is an anonmous array that has the same
 adress, but different content too.
 
 The only explanation is that there is some mem-mapping for each
 httpd-instance, but I dont know much about this.
 
 My problem now is, that each httpd-instance opens a lot of db-handles
 and connections and I end up with system-errors 'to many files opened'
 or such things. 
 
 Is there any way to share handles between all instances (I guess not,
 and I'm sure this mem-mapping has a deeper meaning too: if more than
 one instance access the same adress at the same time there would be
 lot of troubles and I'm even more sure that this has something to do
 with the copy-on-write feature of fork(), but I'm just not good in
 this things, so I'd like to have some comment to be sure that this is
 a principal problem and not a problem of my module)


Peter, in the future posts please consider the following:

1. in perl we don't have pointers, but references. I think you'll be more

understood if you talk using the Perl terminology, rather than C.


2. it helps to diagnose a problem when a *short* (a few lines) code 
example is shown, rather than just describing the symptoms.

This should give you directions to understanding your problem and 
solving it:
1. forked children share the same datastructure with a parent until they 
get modified. When this happens a copy on write occurs and the child 
process doesn't share the datastructure anymore. See: 
http://perl.apache.org/guide/performance.html#Know_Your_Operating_System

2. apparently you have the same problem as 'too many connections' 
problem, and therefore want to look at Apache::DBI for understanding the 
problem and coming up with a similar solution for your problem.


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




dont understand mem-mapping

2001-11-11 Thread Peter Pilsl


I just cant get the following in my brain.  I have a modules that is
started with apache using the PerlModule-directive in httpd.conf.

This module defines a global pointer on startup that should be the
same in all sub-instances of httpd and really in the current
apache-session all instances print out : $g_ptr : HASH(0x8458a30)

This hashpointer is later filled with different values (dbhandles,
filehandles ...) that should kept open over more calls.

Now each session has the same pointer, but the content of the
anonymous hash its pointing too is different in each instance !!

thread 1:
$g_ptr : HASH(0x8458a30)
$g_ptr-{counter} : SCALAR(0x85aa62c)

thread 2:
$g_ptr : HASH(0x8458a30)
$g_ptr-{counter} : SCALAR(0x85f5e2c)

A even more strange example is an anonmous array that has the same
adress, but different content too.

The only explanation is that there is some mem-mapping for each
httpd-instance, but I dont know much about this.

My problem now is, that each httpd-instance opens a lot of db-handles
and connections and I end up with system-errors 'to many files opened'
or such things. 

Is there any way to share handles between all instances (I guess not,
and I'm sure this mem-mapping has a deeper meaning too: if more than
one instance access the same adress at the same time there would be
lot of troubles and I'm even more sure that this has something to do
with the copy-on-write feature of fork(), but I'm just not good in
this things, so I'd like to have some comment to be sure that this is
a principal problem and not a problem of my module)

thnx,
peter

-- 
mag. peter pilsl

phone: +43 676 3574035
fax  : +43 676 3546512
email: [EMAIL PROTECTED]
sms  : [EMAIL PROTECTED]

pgp-key available