You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@locus.apache.org on 2000/03/16 10:51:26 UTC
cvs commit: apache-2.0/src/lib/apr/test testshmem.c
bjh 00/03/16 01:51:26
Modified: src/lib/apr/test testshmem.c
Log:
Clean up shared mem test a bit & add ap_open_shmem() call in child process
to properly gain access to parent's shared memory.
Revision Changes Path
1.3 +10 -5 apache-2.0/src/lib/apr/test/testshmem.c
Index: testshmem.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testshmem.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- testshmem.c 2000/03/10 00:06:34 1.2
+++ testshmem.c 2000/03/16 09:51:26 1.3
@@ -59,6 +59,8 @@
#include "apr_lib.h"
#include "errno.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <process.h>
#ifdef BEOS
#include <unistd.h>
#endif
@@ -74,6 +76,7 @@
{
volatile int test = 0;
while (test == 0) {
+ sleep(0);
test = boxes[boxnum].msgavail;
}
fprintf(stdout, "\nreceived a message in box %d, message was: %s\n",
@@ -89,10 +92,8 @@
int main()
{
- ap_status_t s4;
ap_shmem_t *shm;
pid_t pid;
- ap_status_t s1;
int size;
ap_initialize();
@@ -105,7 +106,7 @@
fprintf(stdout, "OK\n");
fprintf(stdout, "Creating shared memory block.......");
- if (ap_shm_init(&shm, 1048576, NULL) != APR_SUCCESS) {
+ if (ap_shm_init(&shm, 1048576, NULL, context) != APR_SUCCESS) {
fprintf(stderr, "Error allocating shared memory block\n");
exit(-1);
}
@@ -124,8 +125,12 @@
pid = fork();
if (pid == 0) {
sleep(1);
- msgwait(1);
- msgput(0, "Msg received\n");
+ if (ap_open_shmem(shm) == APR_SUCCESS) {
+ msgwait(1);
+ msgput(0, "Msg received\n");
+ } else {
+ puts( "Child: unable to get access to shared memory" );
+ }
exit(1);
}
else if (pid > 0) {