1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
#include "apr_errno.h"
19
#include "apr_general.h"
21
#include "apr_strings.h"
31
#if APR_HAS_SHARED_MEMORY
32
static void msgput(int boxnum, char *msg)
34
apr_cpystrn(boxes[boxnum].msg, msg, strlen(msg) + 1);
35
boxes[boxnum].msgavail = 1;
48
if (apr_pool_create(&pool, NULL) != APR_SUCCESS) {
52
rv = apr_shm_attach(&shm, SHARED_FILENAME, pool);
53
if (rv != APR_SUCCESS) {
57
boxes = apr_shm_baseaddr_get(shm);
59
/* produce messages on all of the boxes, in descending order,
60
* Yes, we could just return N_BOXES, but I want to have a double-check
61
* in this code. The original code actually sent N_BOXES - 1 messages,
62
* so rather than rely on possibly buggy code, this way we know that we
63
* are returning the right number.
65
for (i = N_BOXES - 1, sent = 0; i >= 0; i--, sent++) {
67
apr_sleep(apr_time_from_sec(1));
70
rv = apr_shm_detach(shm);
71
if (rv != APR_SUCCESS) {
78
#else /* APR_HAS_SHARED_MEMORY */
82
/* Just return, this program will never be launched, so there is no
83
* reason to print a message.
88
#endif /* APR_HAS_SHARED_MEMORY */