RE: Forking another process in Apache?

2002-01-22 Thread Chris Hutchinson

We've had a fair amount of success handing long processing jobs off to
daemons (written with Net:Daemon, in most cases passing across args using
Net::Telnet), using pages with reloading redirects to check the daemon
status in a table.

Avoids much work in httpd, and allows user to hang up web connection and
return later to continue viewing status.

- Chris

 -Original Message-
 From: Mike P. Mikhailov [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 22 January 2002 6:04 PM
 To: eCap
 Cc: [EMAIL PROTECTED]
 Subject: Re: Forking another process in Apache?


 Hello eCap,

 Monday, January 21, 2002, 10:45:37 PM, you wrote:

 e A newbie question here...
 e I have a requirement to spin off a SQL loader process after a
 web page (a
 e form which is qualified and accepted) has been submitted.  Does it make
 e sense, or more importantly, is it dangerous to apply a fork
 at the end of
 e a module such as this:


 e sub handler {
 e  # do some qualification stuff here and accept the form submission...
 e  if ($pid = fork) {
 e   # parent
 e   # ...whatever i need to accomplish to deliver return html code
 e   return OK
 e  } elsif {
 e   # child
 e   exec($sql_loader);
 e  } else {
 e   # ...whatever i ned to do to recover errors
 e   return DECLINED
 e  }

 e }

 e Are there any dangers in doing something like this?  Or is there a more
 e efficient way to accomplish the same thing?

 e Thanks for the advice,
 e Kirk


 I'm recently implement exactly such loader. From the client HTTP
 request I'm starting loader with double fork approach. I'm loading
 posssible large enough (about 100 - 150 MB) data from DBF flat files
 into Oracle in single transaction (I'm must provide consistency).
 Loader process takes about 40-50 min to complete and consumes many
 resources (CPU and RAM). But it works !

 --
 WBR, Mike P. Mikhailov
 mailto:[EMAIL PROTECTED]

 Pessimests are right more often, but optimists are happy more often






QUESTION: how to debug segfault apache1.3.22/mod_perl1.26/HTML::Mason

2002-01-20 Thread Chris Hutchinson

I've recently built apache 1.3.22/mod_perl 1.26, statically with perl 
5.6.1 on linux RH 7.0.

Am now getting SIGSEGV at various points in a HTML::Mason web 
application. These happen usually, but not always, when making 
DBD::Pg fetches (happens both with and without Apache::DBI).

This application was working perfectly under perl5.005, 
apache1.3.20/mod_perl 1.24!

Is there any clear way to approach solving this? I've tried tracing 
with strace (output attached below), and rebuilding everything again.

Any suggestions gratefully received, as it's getting a bit desperate here!

- Chris

strace output for _one_ of the crashing pages:

22372 brk(0x8957000)= 0x8957000
22372 read(7, , 4096) = 0
22372 read(7, , 4096) = 0
22372 close(7)  = 0
22372 munmap(0x40019000, 4096)  = 0
22372 stat(/tmp/dms_cache/obj/mc/metaform_submit.mc, 
{st_mode=S_IFREG|0644, st_size=8385, ...}) = 0
22372 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_IGN}, 8) = 0
22372 send(4, Q SELECT Name FROM Species WHERE SpeciesID=2 \0, 46, 
0) = 46
22372 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_IGN}, 8) = 0
22372 select(5, [4], [], [4], NULL) = 1 (in [4])
22372 recv(4, Pblank\0T\0\1name\0\0\0\4\23\377\377\0\0\0$D\200\0\0\0
\17E. GlobulusCSELECT\0Z, 16384, 0) = 51
22372 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
22372 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
22372 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
22372 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_IGN}, 8) = 0
22372 send(4, Q\n\t\t\t\tSELECT 
fieldname,label,valuesource,validsource,controltype,displayorder\n\t\t
\t\tFROM MetaForms,Meta
FormFields\n\t\t\t\tWHERE formname=\'add\' AND 
tablename=\'locationrefs\' \n\t\t\t\tAND 
metaforms.formid=metaformfields.formid
\n\t\t\t\tORDER BY displayorder ASC \0, 245, 0) = 245
22372 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_IGN}, 8) = 0
22372 select(5, [4], [], [4], NULL) = 1 (in [4])
22372 recv(4, Pblank\0T\0\6fieldname\0\0\0\4\23\377\377\0\0\0hlabel\0
\0\0\4\23\377\377\0\0\0hvaluesource\0\0\0\0\31\377\377\3
77\377\377\377validsource\0\0\0\0\31\377\377\377\377\377
\377controltype\0\0\0\4\23\377\377\0\0\0\30displayorder\0\0\0\0\27\0\4
\377\377\377\377D\374\0\0\0\vbatchid\0\0\0\5.\0\0\0007
$value=Trials::getTrialEditBatch($dbi,$parent_key);\0\0\0\4\0\0\0
\10auto
\0\0\0\0050D\374\0\0\0\20lastmodified\0\0\0\0050\0\0\0\4\0\0\0\4\0\0\0
\fauto_now\0\0\0\0050D\374\0\0\0\22lastmodifiedby\0\0\0\
0050\0\0\0\22$value=$G_UID;\0\0\0\4\0\0\0\10auto\0\0\0\0050D\374\0\0\0
\vtrialid\0\0\0\0050\0\0\0\4\0\0\0\4\0\0\0\17auto_parent
\0\0\0\0050D\374\0\0\0\10name\0\0\0\10Name\0\0\0\4\0\0\0\4\0\0\0
\21text_required\0\0\0\0051D\374\0\0\0\17description\0\0\0\17D
escription\0\0\0\4\0\0\0\f$valid=1\0\0\0\ftextarea\0\0\0\0052D\374\0\0
\0\17mg..., 16384, 0) = 805
22372 --- SIGSEGV (Segmentation fault) ---
22372 +++ killed by SIGSEGV +++


Summary of my perl5 (revision 5.0 version 6 subversion 1) 
configuration:
  Platform:
osname=linux, osvers=2.2.16-22, archname=i586-linux
uname='linux laptop 2.2.16-22 #1 tue aug 22 16:16:55 edt 2000 
i586 unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -
D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.96 2731 (Red Hat Linux 7.0)', 
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, 
longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, 
Off_t='off_t', lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.1.92.so, so=so, useshrplib=false, 
libperl=libperl.a
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-
rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'