Manually spawned process and unix domain sockets
Howard May <Howard.May-3Vf4qVogE1JWk0Htik3J/[email protected]> Wed, 17 Aug 2011 10:10:05 -0400
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1851335198408728970==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_F6403A7DAEBDD641B7DA700590C195C6054FE0MBXdialogiccom_"
--_000_F6403A7DAEBDD641B7DA700590C195C6054FE0MBXdialogiccom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
I have the following requirements which I am struggling to meet:
1) Use UNIX domain sockets (named pipes) to communicate (they are on =
the same box)
2) Have a single instance of both lighttpd and myApp running
3) Have multiple simultaneous requests forwarded from Lighttpd at a t=
ime
I have a robust setup which uses TCP connections and works very well. This =
uses the FCGX API to allow myApp to receive multiple requests simultaneousl=
y. All I am trying to do is port this from using tcp connections to using n=
amed pipes. But I have as yet failed to make this work.
I have now reverted to a simple test app which I have included below along =
with my Lighttpd config snipet.
I have set the ownership of everything in a ten mile radius to 'lighttpd'
I would be very grateful for any help or suggestions as to what might be go=
ing wrong.
Best Regards
Howard May
P.S. Konstantin, I have BCCed you explicitly as you had previously offered =
assistance in this area (back in 2009!)
fastcgi.server =3D ( "/namedpipetest/" =3D>
(
(
"socket" =3D> "/var/tmp/lighttpd/wsi-fastcgi.sock=
et",
"check-local" =3D> "disable"
)
)
)
#include <stdio.h>
#include "fcgiapp.h"
void main(int argc, char ** argv)
{
int fd;
int result;
FCGX_Request req;
printf("Fastcgi FIFO test app\n");
result =3D FCGX_Init();
if(result !=3D 0)
{
printf("FCGX_Init returned %d\n", result);
return;
}
fd =3D FCGX_OpenSocket("/var/tmp/lighttpd/wsi-fastcgi.socket", 16);
if(fd =3D=3D 0)
{
printf("FCGX_OpenSocket returned 0\n");
return;
}
FCGX_InitRequest(&req, fd, 0);
while((result =3D FCGX_Accept_r(&req))=3D=3D0);
{
FCGX_FPrintF(req.out, "Content-type: text/html\r\n\r\n<TITLE>Whoop</TIT=
LE>\n");
}
printf("FCGX_Accept_r returned %d\n", result);
return;
}
--_000_F6403A7DAEBDD641B7DA700590C195C6054FE0MBXdialogiccom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"\@MS Mincho";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
@page Section1
{size:595.3pt 841.9pt;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:1657563431;
mso-list-type:hybrid;
mso-list-template-ids:-1854875664 134807569 134807577 134807579 134807567 =
134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
</head>
<body lang=3DEN-GB link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>I have the following requirements which I am struggling =
to meet:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal style=3D'margin-left:.5in;text-indent:-.25in;mso-list:=
l0 level1 lfo1'><![if !supportLists]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'><s=
pan
style=3D'mso-list:Ignore'>1)<font size=3D1 face=3D"Times New Roman"><span
style=3D'font:7.0pt "Times New Roman"'> =
</span></font></span></span></font><![endif]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Us=
e UNIX
domain sockets (named pipes) to communicate (they are on the same box)<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal style=3D'margin-left:.5in;text-indent:-.25in;mso-list:=
l0 level1 lfo1'><![if !supportLists]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'><s=
pan
style=3D'mso-list:Ignore'>2)<font size=3D1 face=3D"Times New Roman"><span
style=3D'font:7.0pt "Times New Roman"'> =
</span></font></span></span></font><![endif]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Ha=
ve a
single instance of both lighttpd and myApp running<o:p></o:p></span></font>=
</p>
<p class=3DMsoNormal style=3D'margin-left:.5in;text-indent:-.25in;mso-list:=
l0 level1 lfo1'><![if !supportLists]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'><s=
pan
style=3D'mso-list:Ignore'>3)<font size=3D1 face=3D"Times New Roman"><span
style=3D'font:7.0pt "Times New Roman"'> =
</span></font></span></span></font><![endif]><font
size=3D2 face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Ha=
ve multiple
simultaneous requests forwarded from Lighttpd at a time<o:p></o:p></span></=
font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>I have a robust setup which uses TCP connections and wor=
ks
very well. This uses the FCGX API to allow myApp to receive multiple reques=
ts
simultaneously. All I am trying to do is port this from using tcp connectio=
ns
to using named pipes. But I have as yet failed to make this work.<o:p></o:p=
></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>I have now reverted to a simple test app which I have
included below along with my Lighttpd config snipet.<o:p></o:p></span></fon=
t></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>I have set the ownership of everything in a ten mile rad=
ius to
‘lighttpd’<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>I would be very grateful for any help or suggestions as =
to
what might be going wrong. <o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>Best Regards<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>Howard May<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>P.S. Konstantin, I have BCCed you explicitly as you had
previously offered assistance in this area (back in 2009!)<o:p></o:p></span=
></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>fastcgi.server =3D ( "/namedpipet=
est/"
=3D><o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;
(<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;  =
;
(<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;  =
;
"socket" =3D> "/var/tmp/lighttpd/wsi-fastcgi.socket"=
,<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;  =
;
"check-local" =3D> "disable"<o:p></o:p></span></font=
></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;  =
;
)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;
)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'> &n=
bsp;
)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>#include <stdio.h>=
;<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>#include
"fcgiapp.h"<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'><o:p> </o:p></span=
></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>void main(int argc, cha=
r **
argv)<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>{<o:p></o:p></span></fo=
nt></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> int fd;<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> int result;<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> FCGX_Request req=
;<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> printf("Fas=
tcgi
FIFO test app\n");<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> result =3D FCGX_=
Init();<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> if(result !=3D 0=
)<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> {<o:p></o:p></sp=
an></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>
printf("FCGX_Init returned %d\n", result);<o:p></o:p></span></fon=
t></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> retu=
rn;<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> }<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> fd =3D
FCGX_OpenSocket("/var/tmp/lighttpd/wsi-fastcgi.socket", 16);<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> if(fd =3D=3D 0)<=
o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> {<o:p></o:p></sp=
an></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>
printf("FCGX_OpenSocket returned 0\n");<o:p></o:p></span></font><=
/p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> retu=
rn;<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> }<o:p></o:p></sp=
an></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>
FCGX_InitRequest(&req, fd, 0);<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'><o:p> </o:p></span=
></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> while((result =
=3D
FCGX_Accept_r(&req))=3D=3D0);<o:p></o:p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> {<o:p></o:p></sp=
an></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>
FCGX_FPrintF(req.out, "Content-type:
text/html\r\n\r\n<TITLE>Whoop</TITLE>\n");<o:p></o:p></spa=
n></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> }<o:p></o:p></sp=
an></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>
printf("FCGX_Accept_r returned %d\n", result);<o:p></o:p></span><=
/font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'> return;<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D1 face=3D"C=
ourier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>}<o:p></o:p></span></fo=
nt></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>
--_000_F6403A7DAEBDD641B7DA700590C195C6054FE0MBXdialogiccom_--
--===============1851335198408728970==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
FastCGI-developers mailing list
FastCGI-developers-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org
http://mailman.fastcgi.com/mailman/listinfo/fastcgi-developers
--===============1851335198408728970==--