~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr-util/include/apr_reslist.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
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
 
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
#ifndef APR_RESLIST_H
 
18
#define APR_RESLIST_H
 
19
 
 
20
/** 
 
21
 * @file apr_reslist.h
 
22
 * @brief APR-UTIL Resource List Routines
 
23
 */
 
24
 
 
25
#include "apr.h"
 
26
#include "apu.h"
 
27
#include "apr_pools.h"
 
28
#include "apr_errno.h"
 
29
#include "apr_time.h"
 
30
 
 
31
#if APR_HAS_THREADS
 
32
 
 
33
/**
 
34
 * @defgroup APR_Util_RL Resource List Routines
 
35
 * @ingroup APR_Util
 
36
 * @{
 
37
 */
 
38
 
 
39
#ifdef __cplusplus
 
40
extern "C" {
 
41
#endif /* __cplusplus */
 
42
 
 
43
/** Opaque resource list object */
 
44
typedef struct apr_reslist_t apr_reslist_t;
 
45
 
 
46
/* Generic constructor called by resource list when it needs to create a
 
47
 * resource.
 
48
 * @param resource opaque resource
 
49
 * @param param flags
 
50
 * @param pool  Pool
 
51
 */
 
52
typedef apr_status_t (*apr_reslist_constructor)(void **resource, void *params,
 
53
                                                apr_pool_t *pool);
 
54
 
 
55
/* Generic destructor called by resource list when it needs to destroy a
 
56
 * resource.
 
57
 * @param resource opaque resource
 
58
 * @param param flags
 
59
 * @param pool  Pool
 
60
 */
 
61
typedef apr_status_t (*apr_reslist_destructor)(void *resource, void *params,
 
62
                                               apr_pool_t *pool);
 
63
 
 
64
/**
 
65
 * Create a new resource list with the following parameters:
 
66
 * @param reslist An address where the pointer to the new resource
 
67
 *                list will be stored.
 
68
 * @param pool The pool to use for local storage and management
 
69
 * @param min Allowed minimum number of available resources. Zero
 
70
 *            creates new resources only when needed.
 
71
 * @param smax Resources will be destroyed to meet this maximum
 
72
 *             restriction as they expire.
 
73
 * @param hmax Absolute maximum limit on the number of total resources.
 
74
 * @param ttl If non-zero, sets the maximum amount of time a resource
 
75
 *               may be available while exceeding the soft limit.
 
76
 * @param con Constructor routine that is called to create a new resource.
 
77
 * @param de Destructor routine that is called to destroy an expired resource.
 
78
 * @param params Passed to constructor and deconstructor
 
79
 * @param pool The pool from which to create this resoure list. Also the
 
80
 *             same pool that is passed to the constructor and destructor
 
81
 *             routines.
 
82
 */
 
83
APU_DECLARE(apr_status_t) apr_reslist_create(apr_reslist_t **reslist,
 
84
                                             int min, int smax, int hmax,
 
85
                                             apr_interval_time_t ttl,
 
86
                                             apr_reslist_constructor con,
 
87
                                             apr_reslist_destructor de,
 
88
                                             void *params,
 
89
                                             apr_pool_t *pool);
 
90
 
 
91
/**
 
92
 * Destroy the given resource list and all resources controlled by
 
93
 * this list.
 
94
 * FIXME: Should this block until all resources become available,
 
95
 *        or maybe just destroy all the free ones, or maybe destroy
 
96
 *        them even though they might be in use by something else?
 
97
 *        Currently it will abort if there are resources that haven't
 
98
 *        been released, so there is an assumption that all resources
 
99
 *        have been released to the list before calling this function.
 
100
 * @param reslist The reslist to destroy
 
101
 */
 
102
APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist);
 
103
 
 
104
/**
 
105
 * Retrieve a resource from the list, creating a new one if necessary.
 
106
 * If we have met our maximum number of resources, we will block
 
107
 * until one becomes available.
 
108
 */
 
109
APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist,
 
110
                                              void **resource);
 
111
 
 
112
/**
 
113
 * Return a resource back to the list of available resources.
 
114
 */
 
115
APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist,
 
116
                                              void *resource);
 
117
 
 
118
/**
 
119
 * Set the timeout the acquire will wait for a free resource
 
120
 * when the maximum number of resources is exceeded.
 
121
 * @param reslist The resource list.
 
122
 * @param timeout Timeout to wait. The zero waits forewer.
 
123
 */
 
124
APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,
 
125
                                          apr_interval_time_t timeout);
 
126
 
 
127
/**
 
128
 * Invalidate a resource in the pool - e.g. a database connection
 
129
 * that returns a "lost connection" error and can't be restored.
 
130
 * Use this instead of apr_reslist_release if the resource is bad.
 
131
 */
 
132
APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist,
 
133
                                                 void *resource);
 
134
 
 
135
 
 
136
#ifdef __cplusplus
 
137
}
 
138
#endif
 
139
 
 
140
/** @} */
 
141
 
 
142
#endif  /* APR_HAS_THREADS */
 
143
 
 
144
#endif  /* ! APR_RESLIST_H */