httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1209606 - in /httpd/httpd/branches/2.4.x: ./ STATUS include/ap_mmn.h modules/session/mod_session.c modules/session/mod_session.h modules/session/mod_session_cookie.c modules/session/mod_session_crypto.c
Date Fri, 02 Dec 2011 17:51:27 GMT
Author: minfrin
Date: Fri Dec  2 17:51:27 2011
New Revision: 1209606

URL: http://svn.apache.org/viewvc?rev=1209606&view=rev
Log:
Backport:
mod_session: Use apr_status_t as a return code across the mod_session API,
clarify where we ignore errors and why.

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/modules/session/mod_session.c
    httpd/httpd/branches/2.4.x/modules/session/mod_session.h
    httpd/httpd/branches/2.4.x/modules/session/mod_session_cookie.c
    httpd/httpd/branches/2.4.x/modules/session/mod_session_crypto.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  2 17:51:27 2011
@@ -1,3 +1,3 @@
 /httpd/httpd/branches/revert-ap-ldap:1150158-1150173
 /httpd/httpd/branches/wombat-integration:723609-723841
-/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601
+/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Fri Dec  2 17:51:27 2011
@@ -96,16 +96,6 @@ RELEASE SHOWSTOPPERS:
 
   NEW ISSUES THAT WOULD BE NICE TO HAVE DONE IN 2.4 BUT ARE NOT BLOCKERS
 
-  * The mod_session* modules need to be checked that their hooks respect
-    the returning of int (HTTP status codes) and apr_status_t as appropriate,
-    and any anomolies fixed.
-    jim sez: from what I can see, mod_session* is no worse that other
-             modules that mix these 2 types... clean up is
-             forthcoming but should not be considered a blocker, imo
-    pgollucci: +1 jim
-    wrowe asks: what's the API change required?
-    wrowe asks; why are we shipping this if it requires apr_ssl
- 
   * mod_ssl's proxy support only allows one proxy client certificate per
     frontend virtual host. Lift this restriction.
     jim sez: Why a blocker?, pgollucci +1 jim

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Fri Dec  2 17:51:27 2011
@@ -372,12 +372,13 @@
  * 20111130.0 (2.4.0-dev)  c->remote_ip becomes c->peer_ip and r->client_ip,
  *                         c->remote_addr becomes c->peer_addr and r->client_addr
  * 20111201.0 (2.5.0-dev)  Add invalidate_entity() to the cache provider.
+ * 20111202.0 (2.5.0-dev)  Use apr_status_t across mod_session API.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20111201
+#define MODULE_MAGIC_NUMBER_MAJOR 20111202
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                   /* 0...n */
 

Modified: httpd/httpd/branches/2.4.x/modules/session/mod_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/session/mod_session.c?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/session/mod_session.c (original)
+++ httpd/httpd/branches/2.4.x/modules/session/mod_session.c Fri Dec  2 17:51:27 2011
@@ -88,8 +88,7 @@ static int session_included(request_rec 
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-/* ??? We return errors but we ignore them thru-out. ??? */
-static int ap_session_load(request_rec * r, session_rec ** z)
+static apr_status_t ap_session_load(request_rec * r, session_rec ** z)
 {
 
     session_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
@@ -168,8 +167,7 @@ static int ap_session_load(request_rec *
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-/* ??? We return errors but we ignore them thru-out. ??? */
-static int ap_session_save(request_rec * r, session_rec * z)
+static apr_status_t ap_session_save(request_rec * r, session_rec * z)
 {
     if (z) {
         apr_time_t now = apr_time_now();
@@ -239,14 +237,21 @@ static int ap_session_save(request_rec *
  * @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)
+static apr_status_t ap_session_get(request_rec * r, session_rec * z,
+        const char *key, const char **value)
 {
     if (!z) {
-        ap_session_load(r, &z); /* errors ignored?? */
+        apr_status_t rv;
+        rv = ap_session_load(r, &z);
+        if (APR_SUCCESS != rv) {
+            return rv;
+        }
     }
     if (z && z->entries) {
         *value = apr_table_get(z->entries, key);
     }
+
+    return OK;
 }
 
 /**
@@ -261,11 +266,15 @@ static void ap_session_get(request_rec *
  * @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)
+static apr_status_t ap_session_set(request_rec * r, session_rec * z,
+        const char *key, const char *value)
 {
     if (!z) {
-        ap_session_load(r, &z); /* errors ignored?? */
+        apr_status_t rv;
+        rv = ap_session_load(r, &z);
+        if (APR_SUCCESS != rv) {
+            return rv;
+        }
     }
     if (z) {
         if (value) {
@@ -276,6 +285,7 @@ static void ap_session_set(request_rec *
         }
         z->dirty = 1;
     }
+    return APR_SUCCESS;
 }
 
 static int identity_count(int *count, const char *key, const char *val)
@@ -314,7 +324,7 @@ static int identity_concat(char *buffer,
  * @param r The request pointer.
  * @param z A pointer to where the session will be written.
  */
-static int session_identity_encode(request_rec * r, session_rec * z)
+static apr_status_t session_identity_encode(request_rec * r, session_rec * z)
 {
 
     char *buffer = NULL;
@@ -350,7 +360,7 @@ static int session_identity_encode(reque
  * @param r The request pointer.
  * @param z A pointer to where the session will be written.
  */
-static int session_identity_decode(request_rec * r, session_rec * z)
+static apr_status_t session_identity_decode(request_rec * r, session_rec * z)
 {
 
     char *last = NULL;
@@ -407,7 +417,7 @@ static int session_identity_decode(reque
  * attempt to save the session will be called
  */
 static apr_status_t session_output_filter(ap_filter_t * f,
-                                                    apr_bucket_brigade * in)
+        apr_bucket_brigade * in)
 {
 
     /* save all the sessions in all the requests */
@@ -421,7 +431,8 @@ static apr_status_t session_output_filte
                                                       &session_module);
 
         /* load the session, or create one if necessary */
-        ap_session_load(r, &z); /* errors ignored?? */
+        /* when unset or on error, z will be NULL */
+        ap_session_load(r, &z);
         if (!z || z->written) {
             r = r->next;
             continue;
@@ -440,7 +451,8 @@ static apr_status_t session_output_filte
         }
 
         /* save away the session, and we're done */
-        ap_session_save(r, z); /* errors ignored?? */
+        /* when unset or on error, we've complained to the log */
+        ap_session_save(r, z);
 
         r = r->next;
     }
@@ -478,9 +490,14 @@ static int session_fixups(request_rec * 
                                                   &session_module);
 
     session_rec *z = NULL;
-    ap_session_load(r, &z); /* errors ignored?? */
 
-    if (conf->env) {
+    /* if an error occurs or no session has been configured, we ignore
+     * the broken session and allow it to be recreated from scratch on save
+     * if necessary.
+     */
+    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);

Modified: httpd/httpd/branches/2.4.x/modules/session/mod_session.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/session/mod_session.h?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/session/mod_session.h (original)
+++ httpd/httpd/branches/2.4.x/modules/session/mod_session.h Fri Dec  2 17:51:27 2011
@@ -125,8 +125,8 @@ typedef struct {
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_load,
-                          (request_rec * r, session_rec ** z))
+APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_load,
+        (request_rec * r, session_rec ** z))
 
 /**
  * Hook to save the session.
@@ -137,8 +137,8 @@ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, i
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_save,
-                          (request_rec * r, session_rec * z))
+APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_save,
+        (request_rec * r, session_rec * z))
 
 /**
  * Hook to encode the session.
@@ -150,8 +150,8 @@ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, i
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_encode,
-                          (request_rec * r, session_rec * z))
+APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_encode,
+        (request_rec * r, session_rec * z))
 
 /**
  * Hook to decode the session.
@@ -163,15 +163,19 @@ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, i
  * @param r The request
  * @param z A pointer to where the session will be written.
  */
-APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, int, session_decode,
-                          (request_rec * r, session_rec * z))
+APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_decode,
+        (request_rec * r, session_rec * z))
 
-APR_DECLARE_OPTIONAL_FN(void, ap_session_get, (request_rec * r, session_rec * z,
-                                               const char *key, const char **value));
-APR_DECLARE_OPTIONAL_FN(void, ap_session_set, (request_rec * r, session_rec * z,
-                                               const char *key, const char *value));
-APR_DECLARE_OPTIONAL_FN(int, ap_session_load, (request_rec *, session_rec **));
-APR_DECLARE_OPTIONAL_FN(int, ap_session_save, (request_rec *, session_rec *));
+APR_DECLARE_OPTIONAL_FN(
+        apr_status_t,
+        ap_session_get,
+        (request_rec * r, session_rec * z, const char *key, const char **value));
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_set,
+        (request_rec * r, session_rec * z, const char *key, const char *value));
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_load,
+        (request_rec *, session_rec **));
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_save,
+        (request_rec *, session_rec *));
 
 /**
  * The name of the module.

Modified: httpd/httpd/branches/2.4.x/modules/session/mod_session_cookie.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/session/mod_session_cookie.c?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/session/mod_session_cookie.c (original)
+++ httpd/httpd/branches/2.4.x/modules/session/mod_session_cookie.c Fri Dec  2 17:51:27 2011
@@ -54,7 +54,7 @@ typedef struct {
  * @param r The request pointer.
  * @param z A pointer to where the session will be written.
  */
-static int session_cookie_save(request_rec * r, session_rec * z)
+static apr_status_t session_cookie_save(request_rec * r, session_rec * z)
 {
 
     session_cookie_dir_conf *conf = ap_get_module_config(r->per_dir_config,
@@ -109,7 +109,7 @@ static int session_cookie_save(request_r
  *
  * On success, this returns APR_SUCCESS.
  */
-static int session_cookie_load(request_rec * r, session_rec ** z)
+static apr_status_t session_cookie_load(request_rec * r, session_rec ** z)
 {
 
     session_cookie_dir_conf *conf = ap_get_module_config(r->per_dir_config,

Modified: httpd/httpd/branches/2.4.x/modules/session/mod_session_crypto.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/session/mod_session_crypto.c?rev=1209606&r1=1209605&r2=1209606&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/session/mod_session_crypto.c (original)
+++ httpd/httpd/branches/2.4.x/modules/session/mod_session_crypto.c Fri Dec  2 17:51:27 2011
@@ -57,11 +57,6 @@ typedef struct {
     int library_set;
 } session_crypto_conf;
 
-AP_DECLARE(int) ap_session_crypto_encode(request_rec * r, session_rec * z);
-AP_DECLARE(int) ap_session_crypto_decode(request_rec * r, session_rec * z);
-AP_DECLARE(int) ap_session_crypto_init(apr_pool_t *p, apr_pool_t *plog,
-        apr_pool_t *ptemp, server_rec *s);
-
 /**
  * Initialise the encryption as per the current config.
  *
@@ -344,7 +339,7 @@ static apr_status_t decrypt_string(reque
  * @param r The request pointer.
  * @param z A pointer to where the session will be written.
  */
-AP_DECLARE(int) ap_session_crypto_encode(request_rec * r, session_rec * z)
+static apr_status_t session_crypto_encode(request_rec * r, session_rec * z)
 {
 
     char *encoded = NULL;
@@ -374,7 +369,8 @@ AP_DECLARE(int) ap_session_crypto_encode
  * @param r The request pointer.
  * @param z A pointer to where the session will be written.
  */
-AP_DECLARE(int) ap_session_crypto_decode(request_rec * r, session_rec * z)
+static apr_status_t session_crypto_decode(request_rec * r,
+        session_rec * z)
 {
 
     char *encoded = NULL;
@@ -402,7 +398,7 @@ AP_DECLARE(int) ap_session_crypto_decode
 /**
  * Initialise the SSL in the post_config hook.
  */
-AP_DECLARE(int) ap_session_crypto_init(apr_pool_t *p, apr_pool_t *plog,
+static int session_crypto_init(apr_pool_t *p, apr_pool_t *plog,
         apr_pool_t *ptemp, server_rec *s)
 {
     const apr_crypto_driver_t *driver = NULL;
@@ -605,9 +601,9 @@ static const command_rec session_crypto_
 
 static void register_hooks(apr_pool_t * p)
 {
-    ap_hook_session_encode(ap_session_crypto_encode, NULL, NULL, APR_HOOK_LAST);
-    ap_hook_session_decode(ap_session_crypto_decode, NULL, NULL, APR_HOOK_FIRST);
-    ap_hook_post_config(ap_session_crypto_init, NULL, NULL, APR_HOOK_LAST);
+    ap_hook_session_encode(session_crypto_encode, NULL, NULL, APR_HOOK_LAST);
+    ap_hook_session_decode(session_crypto_decode, NULL, NULL, APR_HOOK_FIRST);
+    ap_hook_post_config(session_crypto_init, NULL, NULL, APR_HOOK_LAST);
 }
 
 AP_DECLARE_MODULE(session_crypto) =



Mime
View raw message