summaryrefslogtreecommitdiff
path: root/test/testshmconsumer.c
diff options
context:
space:
mode:
authorAaron Bannert <aaron@apache.org>2002-01-22 23:56:23 +0000
committerAaron Bannert <aaron@apache.org>2002-01-22 23:56:23 +0000
commit62736066cd341b3fffd29543917af0d385ddf745 (patch)
tree6f4815f7d03ab3b9e8a45e7444e027bdd466c0e2 /test/testshmconsumer.c
parent6d3db86d98c3c97876b3661abd644b899543277a (diff)
downloadapr-62736066cd341b3fffd29543917af0d385ddf745.tar.gz
Delete the apr_shm_t when we're done with it. (This didn't work before,
but I'm about to commit the implementation.) Add more verbose status/error messages -- most importantly making it obvious from which child (consumer or producer) the messages are comming from. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62815 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testshmconsumer.c')
-rw-r--r--test/testshmconsumer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/testshmconsumer.c b/test/testshmconsumer.c
index 045ce7e66..6fcf4b72f 100644
--- a/test/testshmconsumer.c
+++ b/test/testshmconsumer.c
@@ -84,14 +84,14 @@ static void msgwait(int sleep_sec, int first_box, int last_box)
while (apr_time_now() - start < sleep_sec * APR_USEC_PER_SEC) {
for (i = first_box; i < last_box; i++) {
if (boxes[i].msgavail) {
- fprintf(stdout, "received a message in box %d, message was: %s\n",
+ fprintf(stdout, "Consumer: received a message in box %d, message was: %s\n",
i, boxes[i].msg);
boxes[i].msgavail = 0; /* reset back to 0 */
}
}
apr_sleep(1*APR_USEC_PER_SEC);
}
- fprintf(stdout, "done waiting on mailboxes...\n");
+ fprintf(stdout, "Consumer: done waiting on mailboxes...\n");
}
int main(void)
@@ -112,24 +112,30 @@ int main(void)
}
printf("OK\n");
+ printf("Consumer attaching to name-based shared memory....");
rv = apr_shm_attach(&shm, SHARED_FILENAME, pool);
if (rv != APR_SUCCESS) {
- printf("Unable to attach to name-based shared memory segment: "
- "[%d] %s \n", rv, apr_strerror(rv, errmsg, sizeof(errmsg)));
+ printf("Consumer unable to attach to name-based shared memory "
+ "segment: [%d] %s \n", rv,
+ apr_strerror(rv, errmsg, sizeof(errmsg)));
exit(-2);
}
+ printf("OK\n");
boxes = apr_shm_baseaddr_get(shm);
/* consume messages on all of the boxes */
msgwait(30, 0, N_BOXES); /* wait for 30 seconds for messages */
+ printf("Consumer detaching from name-based shared memory....");
rv = apr_shm_detach(shm);
if (rv != APR_SUCCESS) {
- printf("Unable to detach from name-based shared memory segment: "
- "[%d] %s \n", rv, apr_strerror(rv, errmsg, sizeof(errmsg)));
+ printf("Consumer unable to detach from name-based shared memory "
+ "segment: [%d] %s \n", rv,
+ apr_strerror(rv, errmsg, sizeof(errmsg)));
exit(-3);
}
+ printf("OK\n");
return 0;
}