MCPcopy Create free account
hub / github.com/apache/httpd / socache_dbm_init

Function socache_dbm_init

modules/cache/mod_socache_dbm.c:119–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx,
120 const char *namespace,
121 const struct ap_socache_hints *hints,
122 server_rec *s, apr_pool_t *p)
123{
124#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
125 const apr_dbm_driver_t *driver;
126 const apu_err_t *err;
127#endif
128 apr_dbm_t *dbm;
129 apr_status_t rv;
130
131 /* for the DBM we need the data file */
132 if (ctx->data_file == NULL) {
133 const char *path = apr_pstrcat(p, DEFAULT_DBM_PREFIX, namespace,
134 NULL);
135
136 ctx->data_file = ap_runtime_dir_relative(p, path);
137
138 if (ctx->data_file == NULL) {
139 ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00803)
140 "could not use default path '%s' for DBM socache",
141 path);
142 return APR_EINVAL;
143 }
144 }
145
146 /* open it once to create it and to make sure it _can_ be created */
147 apr_pool_clear(ctx->pool);
148
149#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
150 if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
151 ctx->pool) != APR_SUCCESS) {
152 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10277)
153 "Cannot load socache DBM library '%s': %s",
154 err->reason, err->msg);
155 return rv;
156 }
157 if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file,
158 APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
159 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
160 "Cannot create socache DBM file `%s'",
161 ctx->data_file);
162 return DECLINED;
163 }
164#else
165 if ((rv = apr_dbm_open(&dbm, ctx->data_file,
166 APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
167 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
168 "Cannot create socache DBM file `%s'",
169 ctx->data_file);
170 return rv;
171 }
172#endif
173 apr_dbm_close(dbm);
174
175 ctx->expiry_interval = (hints && hints->expiry_interval
176 ? hints->expiry_interval : apr_time_from_sec(30));

Callers

nothing calls this directly

Calls 4

ap_runtime_dir_relativeFunction · 0.85
try_chownFunction · 0.85
socache_dbm_expireFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected