Apache HTTPD
testshmproducer.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "apr_shm.h"
18#include "apr_errno.h"
19#include "apr_general.h"
20#include "apr_lib.h"
21#include "apr_strings.h"
22#include "apr_time.h"
23#include "testshm.h"
24#include "apr.h"
25
26#if APR_HAVE_STDLIB_H
27#include <stdlib.h>
28#endif
29
30
31#if APR_HAS_SHARED_MEMORY
32
33int main(void)
34{
35 apr_status_t rv;
38 int i;
39 int sent = 0;
40
42
44 exit(-1);
45 }
46
48 if (rv != APR_SUCCESS) {
49 exit(-2);
50 }
51
53
54 /* produce messages on all of the boxes, in descending order,
55 * Yes, we could just return N_BOXES, but I want to have a double-check
56 * in this code. The original code actually sent N_BOXES - 1 messages,
57 * so rather than rely on possibly buggy code, this way we know that we
58 * are returning the right number.
59 */
60 for (i = N_BOXES - 1, sent = 0; i >= 0; i--, sent++) {
61 msgput(MSG, i);
63 }
64
65 rv = apr_shm_detach(shm);
66 if (rv != APR_SUCCESS) {
67 exit(-3);
68 }
69
70 return sent;
71}
72
73#else /* APR_HAS_SHARED_MEMORY */
74
75int main(void)
76{
77 /* Just return, this program will never be launched, so there is no
78 * reason to print a message.
79 */
80 return 0;
81}
82
83#endif /* APR_HAS_SHARED_MEMORY */
84
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Shared Memory Routines.
APR Strings library.
APR Time Library.
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
#define apr_pool_create(newpool, parent)
Definition apr_pools.h:322
apr_shm_t * shm
#define apr_time_from_sec(sec)
Definition apr_time.h:78
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
#define MSG
Definition testshm.h:37
mbox * boxes
Definition testshm.h:31
#define SHARED_FILENAME
Definition testshm.h:36
#define N_BOXES
Definition testshm.h:33
int main(void)