Skip to content

Commit 1d5c7d6

Browse files
committed
cache/common.c: add some doc
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 8b2cb99 commit 1d5c7d6

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/cache/common.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ char *oidc_cache_status2str(apr_pool_t *p, apr_status_t statcode) {
8080
return apr_pstrdup(p, buf);
8181
}
8282

83+
/*
84+
* create a server-wide mutex
85+
*/
8386
static apr_byte_t oidc_cache_mutex_global_create(apr_pool_t *pool, server_rec *s, oidc_cache_mutex_t *m,
8487
const char *type) {
8588

@@ -109,10 +112,25 @@ static apr_byte_t oidc_cache_mutex_global_create(apr_pool_t *pool, server_rec *s
109112
;
110113

111114
// TODO: need to allocate this on the server process pool to avoid crashes on
112-
// oidc_cache_mutex_unlock at shutdown time on graceful restarts,
115+
// oidc_cache_mutex_unlock at shutdown time on graceful restarts
113116
// and test/helper.c shutdown; is it because libapr cleaned it up before us?
114117

115-
// it is probably related to the remaining valgrind report on possibly lost memory:
118+
/*
119+
* ==54== Invalid read of size 4
120+
* ==54== at 0x4A1C1D0: sem_post@@GLIBC_2.34 (sem_post.c:35)
121+
* ==54== by 0x49626F7: ??? (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.7.5)
122+
* ==54== by 0x4962065: apr_global_mutex_unlock (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.7.5)
123+
* ==54== by 0x5A40F9B: oidc_cache_mutex_unlock (common.c:259)
124+
* ==54== by 0x5A3FF51: oidc_cache_shm_destroy (shm.c:334)
125+
* ==54== by 0x5A33F53: oidc_cfg_server_destroy (cfg.c:700)
126+
* ==54== by 0x4964A4D: apr_pool_destroy (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.7.5)
127+
* ==54== by 0x4964A2C: apr_pool_destroy (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.7.5)
128+
* ==54== by 0x142767: ??? (in /usr/sbin/apache2)
129+
* ==54== by 0x14223A: main (in /usr/sbin/apache2)
130+
* ==54== Address 0x5abb008 is not stack'd, malloc'd or (recently) free'd
131+
*/
132+
133+
// could it be related to the remaining valgrind report on possibly lost memory: ?
116134

117135
/*
118136
* ==73== 24 bytes in 1 blocks are possibly lost in loss record 39 of 176
@@ -156,14 +174,17 @@ static apr_byte_t oidc_cache_mutex_global_create(apr_pool_t *pool, server_rec *s
156174
return TRUE;
157175
}
158176

177+
/*
178+
* initialize a server- or process-wide mutex
179+
*/
159180
apr_byte_t oidc_cache_mutex_post_config(apr_pool_t *pool, server_rec *s, oidc_cache_mutex_t *m, const char *type) {
160181

161182
apr_status_t rv = APR_SUCCESS;
162183

163184
if (m->is_global)
164185
return oidc_cache_mutex_global_create(pool, s, m, type);
165186

166-
// NB: see note above at apr_global_mutex_create
187+
// NB: see note above at apr_global_mutex_create on the use of s->process->pool
167188
rv = apr_thread_mutex_create(&m->tmutex, APR_THREAD_MUTEX_DEFAULT, s->process->pool);
168189
if (rv != APR_SUCCESS) {
169190
oidc_serror(s, "apr_thread_mutex_create failed: %s (%d)", oidc_cache_status2str(pool, rv), rv);

0 commit comments

Comments
 (0)