Loading modules/session/mod_session.c +64 −61 Changes for modules/session/mod_session.c: 64 added lines, 61 removed lines. Original line number Diff line number Diff line Loading @@ -32,13 +32,13 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(session_encode) APR_HOOK_LINK(session_decode) ) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(session, SESSION, int, session_load, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap, SESSION, int, session_load, (request_rec * r, session_rec ** z), (r, z), DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(session, SESSION, int, session_save, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap, SESSION, int, session_save, (request_rec * r, session_rec * z), (r, z), DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(session, SESSION, int, session_encode, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap, SESSION, int, session_encode, (request_rec * r, session_rec * z), (r, z), OK, DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(session, SESSION, int, session_decode, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap, SESSION, int, session_decode, (request_rec * r, session_rec * z), (r, z), OK, DECLINED) static int session_identity_encode(request_rec * r, session_rec * z); Loading Loading @@ -81,54 +81,6 @@ static int session_included(request_rec * r, session_dir_conf * conf) return included; } /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ SESSION_DECLARE(void) ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value) { if (!z) { ap_session_load(r, &z); } if (z && z->entries) { *value = apr_table_get(z->entries, key); } } /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value) { if (!z) { ap_session_load(r, &z); } if (z) { if (value) { apr_table_set(z->entries, key, value); } else { apr_table_unset(z->entries, key); } z->dirty = 1; } } /** * Load the session. * Loading @@ -137,7 +89,7 @@ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z) static int ap_session_load(request_rec * r, session_rec ** z) { session_dir_conf *dconf = ap_get_module_config(r->per_dir_config, Loading Loading @@ -216,7 +168,7 @@ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z) * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z) static int ap_session_save(request_rec * r, session_rec * z) { if (z) { apr_time_t now = apr_time_now(); Loading Loading @@ -268,6 +220,54 @@ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z) } /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ static void ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value) { if (!z) { ap_session_load(r, &z); } if (z && z->entries) { *value = apr_table_get(z->entries, key); } } /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ static void ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value) { if (!z) { ap_session_load(r, &z); } if (z) { if (value) { apr_table_set(z->entries, key, value); } else { apr_table_unset(z->entries, key); } z->dirty = 1; } } static int identity_count(int *count, const char *key, const char *val) { *count += strlen(key) * 3 + strlen(val) * 3 + 1; Loading Loading @@ -396,7 +396,7 @@ static int session_identity_decode(request_rec * r, session_rec * z) * The same session might appear in more than one request. The first * attempt to save the session will be called */ static apr_status_t ap_session_output_filter(ap_filter_t * f, static apr_status_t session_output_filter(ap_filter_t * f, apr_bucket_brigade * in) { Loading Loading @@ -446,7 +446,7 @@ static apr_status_t ap_session_output_filter(ap_filter_t * f, /** * Insert the output filter. */ static void ap_session_insert_output_filter(request_rec * r) static void session_insert_output_filter(request_rec * r) { ap_add_output_filter("MOD_SESSION_OUT", NULL, r, r->connection); } Loading Loading @@ -599,14 +599,17 @@ static const command_rec session_cmds[] = static void register_hooks(apr_pool_t * p) { ap_register_output_filter("MOD_SESSION_OUT", ap_session_output_filter, ap_register_output_filter("MOD_SESSION_OUT", session_output_filter, NULL, AP_FTYPE_CONTENT_SET); ap_hook_insert_filter(ap_session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_insert_error_filter(ap_session_insert_output_filter, ap_hook_insert_filter(session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_insert_error_filter(session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_fixups(session_fixups, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_session_encode(session_identity_encode, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_session_decode(session_identity_decode, NULL, NULL, APR_HOOK_REALLY_LAST); ap_hook_session_encode(session_identity_encode, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_session_decode(session_identity_decode, NULL, NULL, APR_HOOK_REALLY_LAST); APR_REGISTER_OPTIONAL_FN(ap_session_get); APR_REGISTER_OPTIONAL_FN(ap_session_set); APR_REGISTER_OPTIONAL_FN(ap_session_load); Loading modules/session/mod_session.h +4 −51 Changes for modules/session/mod_session.h: 4 added lines, 51 removed lines. Original line number Diff line number Diff line Loading @@ -117,42 +117,6 @@ typedef struct { * URLs excluded if empty */ } session_dir_conf; /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ SESSION_DECLARE(void) ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value); /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value); /** * Load the session. * * If the session doesn't exist, a blank one will be created. * * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z); /** * Hook to load the session. * Loading @@ -161,20 +125,9 @@ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z); * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_load, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_load, (request_rec * r, session_rec ** z)) /** * Save the session. * * In most implementations the session is only saved if the dirty flag is * true. This prevents the session being saved unnecessarily. * * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z); /** * Hook to save the session. * Loading @@ -184,7 +137,7 @@ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z); * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_save, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_save, (request_rec * r, session_rec * z)) /** Loading @@ -197,7 +150,7 @@ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_save, * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_encode, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_encode, (request_rec * r, session_rec * z)) /** Loading @@ -210,7 +163,7 @@ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_encode, * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_decode, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_decode, (request_rec * r, session_rec * z)) APR_DECLARE_OPTIONAL_FN(void, ap_session_get, (request_rec * r, session_rec * z, Loading Loading
modules/session/mod_session.c +64 −61 Changes for modules/session/mod_session.c: 64 added lines, 61 removed lines. Original line number Diff line number Diff line Loading @@ -32,13 +32,13 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(session_encode) APR_HOOK_LINK(session_decode) ) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(session, SESSION, int, session_load, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap, SESSION, int, session_load, (request_rec * r, session_rec ** z), (r, z), DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(session, SESSION, int, session_save, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap, SESSION, int, session_save, (request_rec * r, session_rec * z), (r, z), DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(session, SESSION, int, session_encode, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap, SESSION, int, session_encode, (request_rec * r, session_rec * z), (r, z), OK, DECLINED) APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(session, SESSION, int, session_decode, APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap, SESSION, int, session_decode, (request_rec * r, session_rec * z), (r, z), OK, DECLINED) static int session_identity_encode(request_rec * r, session_rec * z); Loading Loading @@ -81,54 +81,6 @@ static int session_included(request_rec * r, session_dir_conf * conf) return included; } /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ SESSION_DECLARE(void) ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value) { if (!z) { ap_session_load(r, &z); } if (z && z->entries) { *value = apr_table_get(z->entries, key); } } /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value) { if (!z) { ap_session_load(r, &z); } if (z) { if (value) { apr_table_set(z->entries, key, value); } else { apr_table_unset(z->entries, key); } z->dirty = 1; } } /** * Load the session. * Loading @@ -137,7 +89,7 @@ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z) static int ap_session_load(request_rec * r, session_rec ** z) { session_dir_conf *dconf = ap_get_module_config(r->per_dir_config, Loading Loading @@ -216,7 +168,7 @@ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z) * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z) static int ap_session_save(request_rec * r, session_rec * z) { if (z) { apr_time_t now = apr_time_now(); Loading Loading @@ -268,6 +220,54 @@ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z) } /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ static void ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value) { if (!z) { ap_session_load(r, &z); } if (z && z->entries) { *value = apr_table_get(z->entries, key); } } /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ static void ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value) { if (!z) { ap_session_load(r, &z); } if (z) { if (value) { apr_table_set(z->entries, key, value); } else { apr_table_unset(z->entries, key); } z->dirty = 1; } } static int identity_count(int *count, const char *key, const char *val) { *count += strlen(key) * 3 + strlen(val) * 3 + 1; Loading Loading @@ -396,7 +396,7 @@ static int session_identity_decode(request_rec * r, session_rec * z) * The same session might appear in more than one request. The first * attempt to save the session will be called */ static apr_status_t ap_session_output_filter(ap_filter_t * f, static apr_status_t session_output_filter(ap_filter_t * f, apr_bucket_brigade * in) { Loading Loading @@ -446,7 +446,7 @@ static apr_status_t ap_session_output_filter(ap_filter_t * f, /** * Insert the output filter. */ static void ap_session_insert_output_filter(request_rec * r) static void session_insert_output_filter(request_rec * r) { ap_add_output_filter("MOD_SESSION_OUT", NULL, r, r->connection); } Loading Loading @@ -599,14 +599,17 @@ static const command_rec session_cmds[] = static void register_hooks(apr_pool_t * p) { ap_register_output_filter("MOD_SESSION_OUT", ap_session_output_filter, ap_register_output_filter("MOD_SESSION_OUT", session_output_filter, NULL, AP_FTYPE_CONTENT_SET); ap_hook_insert_filter(ap_session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_insert_error_filter(ap_session_insert_output_filter, ap_hook_insert_filter(session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_insert_error_filter(session_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_fixups(session_fixups, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_session_encode(session_identity_encode, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_session_decode(session_identity_decode, NULL, NULL, APR_HOOK_REALLY_LAST); ap_hook_session_encode(session_identity_encode, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_session_decode(session_identity_decode, NULL, NULL, APR_HOOK_REALLY_LAST); APR_REGISTER_OPTIONAL_FN(ap_session_get); APR_REGISTER_OPTIONAL_FN(ap_session_set); APR_REGISTER_OPTIONAL_FN(ap_session_load); Loading
modules/session/mod_session.h +4 −51 Changes for modules/session/mod_session.h: 4 added lines, 51 removed lines. Original line number Diff line number Diff line Loading @@ -117,42 +117,6 @@ typedef struct { * URLs excluded if empty */ } session_dir_conf; /** * Get a particular value from the session. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to get. * @param value The buffer to write the value to. */ SESSION_DECLARE(void) ap_session_get(request_rec * r, session_rec * z, const char *key, const char **value); /** * Set a particular value to the session. * * Using this method ensures that the dirty flag is set correctly, so that * the session can be saved efficiently. * @param r The current request. * @param z The current session. If this value is NULL, the session will be * looked up in the request, created if necessary, and saved to the request * notes. * @param key The key to set. The existing key value will be replaced. * @param value The value to set. */ SESSION_DECLARE(void) ap_session_set(request_rec * r, session_rec * z, const char *key, const char *value); /** * Load the session. * * If the session doesn't exist, a blank one will be created. * * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z); /** * Hook to load the session. * Loading @@ -161,20 +125,9 @@ SESSION_DECLARE(int) ap_session_load(request_rec * r, session_rec ** z); * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_load, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_load, (request_rec * r, session_rec ** z)) /** * Save the session. * * In most implementations the session is only saved if the dirty flag is * true. This prevents the session being saved unnecessarily. * * @param r The request * @param z A pointer to where the session will be written. */ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z); /** * Hook to save the session. * Loading @@ -184,7 +137,7 @@ SESSION_DECLARE(int) ap_session_save(request_rec * r, session_rec * z); * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_save, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_save, (request_rec * r, session_rec * z)) /** Loading @@ -197,7 +150,7 @@ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_save, * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_encode, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_encode, (request_rec * r, session_rec * z)) /** Loading @@ -210,7 +163,7 @@ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_encode, * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(session, SESSION, int, session_decode, APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_decode, (request_rec * r, session_rec * z)) APR_DECLARE_OPTIONAL_FN(void, ap_session_get, (request_rec * r, session_rec * z, Loading