diff options
author | aaron <aaron@13f79535-47bb-0310-9956-ffa450edef68> | 2002-01-22 23:56:23 +0000 |
---|---|---|
committer | aaron <aaron@13f79535-47bb-0310-9956-ffa450edef68> | 2002-01-22 23:56:23 +0000 |
commit | bac68779f82e83cde2e36cc71b68b8de6d3d7376 (patch) | |
tree | 6f4815f7d03ab3b9e8a45e7444e027bdd466c0e2 /test/testshmconsumer.c | |
parent | 91ef2de2c79231c51f1454e1e5dd4835fc78376f (diff) | |
download | libapr-bac68779f82e83cde2e36cc71b68b8de6d3d7376.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: http://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.c | 18 |
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; } |