/* found a session that hasn't expired? */
now = apr_time_now();
- if (!zz || (zz->expiry && zz->expiry < now)) {
+ if (zz) {
+ if (zz->expiry && zz->expiry < now) {
+ zz = NULL;
+ }
+ else {
+ /* having a session we cannot decode is just as good as having
+ none at all */
+ rv = ap_run_session_decode(r, zz);
+ if (OK != rv) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01817)
+ "error while decoding the session, "
+ "session not loaded: %s", r->uri);
+ zz = NULL;
+ }
+ }
+ }
- /* no luck, create a blank session */
+ /* no luck, create a blank session */
+ if (!zz) {
zz = (session_rec *) apr_pcalloc(r->pool, sizeof(session_rec));
zz->pool = r->pool;
zz->entries = apr_table_make(zz->pool, 10);
-
- }
- else {
- rv = ap_run_session_decode(r, zz);
- if (OK != rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01817)
- "error while decoding the session, "
- "session not loaded: %s", r->uri);
- return rv;
- }
}
/* make sure the expiry and maxage are set, if present */
return APR_SUCCESS;
}
-static int identity_count(int *count, const char *key, const char *val)
+static int identity_count(void *v, const char *key, const char *val)
{
+ int *count = v;
*count += strlen(key) * 3 + strlen(val) * 3 + 1;
return 1;
}
-static int identity_concat(char *buffer, const char *key, const char *val)
+static int identity_concat(void *v, const char *key, const char *val)
{
- char *slider = buffer;
+ char *slider = v;
int length = strlen(slider);
slider += length;
if (length) {
char *expiry = apr_psprintf(z->pool, "%" APR_INT64_T_FMT, z->expiry);
apr_table_setn(z->entries, SESSION_EXPIRY, expiry);
}
- apr_table_do((int (*) (void *, const char *, const char *))
- identity_count, &length, z->entries, NULL);
+ apr_table_do(identity_count, &length, z->entries, NULL);
buffer = apr_pcalloc(r->pool, length + 1);
- apr_table_do((int (*) (void *, const char *, const char *))
- identity_concat, buffer, z->entries, NULL);
+ apr_table_do(identity_concat, buffer, z->entries, NULL);
z->encoded = buffer;
return OK;
*/
ap_session_load(r, &z);
- if (z && conf->env) {
- session_identity_encode(r, z);
- if (z->encoded) {
- apr_table_set(r->subprocess_env, HTTP_SESSION, z->encoded);
- z->encoded = NULL;
+ if (conf->env) {
+ if (z) {
+ session_identity_encode(r, z);
+ if (z->encoded) {
+ apr_table_set(r->subprocess_env, HTTP_SESSION, z->encoded);
+ z->encoded = NULL;
+ }
}
+ apr_table_unset(r->headers_in, "Session");
}
return OK;