[Info-vax] Apache + mod_php performance
Mark Daniel
mark.daniel at wasd.vsm.com.au
Mon Oct 7 15:05:49 EDT 2024
On 8/10/2024 03:17, Mark Berryman wrote:
> On 10/6/24 9:12 AM, Michael S wrote:
8< snip 8<
>> As a lurker, I am waiting for the expert answer with interest.
>>
>
> It is most definitely possible as that is precisely what the auxiliary
> server in TCPIP Services does. It listens for a connection, then
> creates a process to handle it. See the description of TCPIP$C_AUXS in
> the TCPIP Services programming documentation.
8< snip 8<
The auxiliary is something special. Passing socket devices between
processes requires SHARE privilege.
X86VMS$ type bg_example.c
/*****************************************************************************/
/*
Quick and dirty demonstrator of passing BSD socket using BG device name
to another process and using that to QIO and write(). IPC is simple
system(). Cobbled together from various project fragments.
$ cc bg_example
$ link bg_example
$ mcr []bg_example
$ telnet loalhost 8765
accept()
chan: 304
BgDevice: |BG12433:|
sys$setprv() %X00000001
sys$assign() %X00000001
sys$qiow() 14 %X00000001 %X00000001
write() 14 %X00000001
dcl: |mcr dka100:[kits]bg_example.exe;14 BG12433:| %X00000001
accept()
Comment out the initial $setprv(PRV$M_SHARE) and the channel is not
allocated.
accept()
chan: 304
BgDevice: |BG12677:|
write() -1 %X0000013C
dcl: |mcr dka100:[kits]bg_example.exe;17 BG12677:| %X00000001
accept()
*/
/*****************************************************************************/
#include <ctype.h>
#include <descrip.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <types.h>
#include <unixlib.h>
#include <unistd.h>
#include <dvidef.h>
#include <efndef.h>
#include <iodef.h>
#include <lnmdef.h>
#include <prvdef.h>
#include <ssdef.h>
#include <starlet.h>
#include <sys/socket.h>
#include <resolv.h>
#include <netdb.h>
typedef struct iosb_t
{
ushort iosb$w_status;
ushort iosb$w_bcnt;
ulong iosb$l_reserved;
}
iosb;
static ulong ShareMask [2] = { PRV$M_SHARE, 0 };
static int EfnWait = EFN$C_ENF;
int ListenBegin ();
int OpenBG (char*);
char* GetBgDevice (ushort);
/*****************************************************************************/
/*
*/
int main (int argc, char *argv[])
{
if (argc > 1)
OpenBG (argv[1]);
else
ListenBegin (argv[0]);
}
/*****************************************************************************/
/*
Set up a socket listening to port 8765.
*/
int ListenBegin (char *argv0)
{
static int one = 1;
int csock, lsock, status;
uint clen;
ushort chan;
struct sockaddr_in caddr;
struct sockaddr_in laddr;
char *cptr;
char dcl [256];
/*********/
/* begin */
/*********/
memset (&laddr, 0, sizeof(laddr));
laddr.sin_family = AF_INET;
laddr.sin_addr.s_addr = INADDR_ANY;
laddr.sin_port = htons(8765);
if ((lsock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
return (vaxc$errno);
if (setsockopt (lsock, SOL_SOCKET, SO_REUSEADDR,
&one, sizeof(one)) < 0)
{
close (lsock);
return (vaxc$errno);
}
if (bind (lsock, (struct sockaddr*)&laddr, sizeof(laddr)) < 0)
{
close (lsock);
return (vaxc$errno);
}
if (listen (lsock, 5) < 0)
{
close (lsock);
return (vaxc$errno);
}
for (;;)
{
clen = sizeof(caddr);
printf ("accept()\n");
csock = accept (lsock, (struct sockaddr*)&caddr, &clen);
if (csock < 0)
{
status = vaxc$errno;
if (status == SS$_CANCEL || SS$_IVCHAN) break;
continue;
}
chan = decc$get_sdc (csock);
printf ("chan: %d\n", chan);
if (!chan) return (vaxc$errno);
cptr = GetBgDevice (chan);
printf ("BgDevice: |%s|\n", cptr);
sprintf (dcl, "mcr %s %s", argv0, cptr);
status = system (dcl);
printf ("dcl: |%s| %%X%08.08X\n", dcl, status);
if (!(status & 1)) break;
close (csock);
}
close (lsock);
return (status);
}
/*****************************************************************************/
/*
Open shared the supplied BG device name.
*/
int OpenBG (char *BgDevName)
{
int count, csock, status;
ushort chan;
iosb IOsb;
$DESCRIPTOR (BgDevNameDsc, BgDevName);
BgDevNameDsc.dsc$w_length = strlen(BgDevName);
status = sys$setprv (1, &ShareMask, 0, 0);
printf ("sys$setprv() %%X%08.08X\n", status);
if (status & 1)
{
BgDevNameDsc.dsc$w_length = strlen(BgDevName);
status = sys$assign (&BgDevNameDsc, &chan, 0, 0);
printf ("sys$assign() %%X%08.08X\n", status);
}
if (status & 1)
{
status = sys$qiow (EfnWait, chan, IO$_WRITEVBLK, &IOsb, 0, 0,
"\r\nabcdefghij\r\n", 14, 0, 0, 0, 0);
printf ("sys$qiow() %d %%X%08.08X %%X%08.08X\n",
IOsb.iosb$w_bcnt, status, IOsb.iosb$w_status);
if (status & 1)
status = IOsb.iosb$w_status;
}
csock = decc$socket_fd (chan);
if (csock == -1) status = vaxc$errno;
if (csock > 0)
{
count = write (csock, "\r\nklmnopqrst\r\n", 14);
if (count != 14) status = vaxc$errno;
printf ("write() %d %%X%08.08X\n", count, status);
}
sys$setprv (0, &ShareMask, 0, 0);
sys$dassgn (chan);
return (status);
}
/*****************************************************************************/
/*
Just get the "BGnnn:" device name associated with the channel.
*/
char* GetBgDevice (ushort Channel)
{
static char DevName [65];
static ushort slen;
struct ItemList3Struct
{
ushort buf_len;
ushort item;
void *buf_addr;
void *ret_len;
} DevNamItemList [] =
{
{ sizeof(DevName)-1, DVI$_DEVNAM, DevName, &slen },
{ 0, 0, 0, 0 }
};
int status;
iosb IOsb;
/*********/
/* begin */
/*********/
if (!Channel)
{
memset (DevName, 0, sizeof(DevName));
return (DevName);
}
status = sys$getdviw (EfnWait, Channel, 0, &DevNamItemList,
&IOsb, 0, 0, 0);
if (status & 1) status = IOsb.iosb$w_status;
if (status & 1)
DevName[slen] = '\0';
else
sprintf (DevName, "%%X%08.08X", status);
if (DevName[0] == '_') return (DevName+1);
return (DevName);
}
/*****************************************************************************/
--
Anyone, who using social-media, forms an opinion regarding anything
other than the relative cuteness of this or that puppy-dog, needs
seriously to examine their critical thinking.
More information about the Info-vax
mailing list