Hello,
Ever noticed the following set of messages in the error_log - they can really
fill up the log file pretty quickly! I can't really get much useful information (and I
don't even know what 'internal error' means ?)
-------------------------------------------
[Wed Mar 24 13:55:46 2004] [error] shmcb_insert_encoded_session internal error
[Wed Mar 24 13:55:46 2004] [error] can't store a session!
[Wed Mar 24 13:55:46 2004] [error] 'shmcb' code was unable to store a session in
the cache.
-------------------------------------------
I was thinking of reducing the clutter to just one line and make the messages more
meaningful to something like:
[Wed Mar 24 13:55:46 2004] [error] 'shmcb' was unable to store a session in the cache
[cause: cache full]
Here's a patch (with work in progress) attached. Any suggestions/objections ?
Thanks
-Madhu
RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_scache_shmcb.c,v
retrieving revision 1.25
diff -u -r1.25 ssl_scache_shmcb.c
--- ssl_scache_shmcb.c 28 Feb 2004 18:06:35 -0000 1.25
+++ ssl_scache_shmcb.c 24 Mar 2004 22:22:40 -0000
@@ -195,6 +195,9 @@
unsigned char *data;
} SHMCBCache;
+#define SSL_INTERNAL_ERROR -1
+#define SSL_SESSION_TOO_BIG -2
+
/*
* Forward function prototypes.
*/
@@ -242,7 +245,7 @@
/* Underlying functions for session-caching */
static BOOL shmcb_init_memory(server_rec *, void *, unsigned int);
-static BOOL shmcb_store_session(server_rec *, void *, UCHAR *, int, SSL_SESSION *,
time_t);
+static int shmcb_store_session(server_rec *, void *, UCHAR *, int, SSL_SESSION *,
time_t);
static SSL_SESSION *shmcb_retrieve_session(server_rec *, void *, UCHAR *, int);
static BOOL shmcb_remove_session(server_rec *, void *, UCHAR *, int);
@@ -251,7 +254,7 @@
static BOOL shmcb_get_division(SHMCBHeader *, SHMCBQueue *, SHMCBCache *, unsigned
int);
static SHMCBIndex *shmcb_get_index(const SHMCBQueue *, unsigned int);
static unsigned int shmcb_expire_division(server_rec *, SHMCBQueue *, SHMCBCache *);
-static BOOL shmcb_insert_encoded_session(server_rec *, SHMCBQueue *, SHMCBCache *,
unsigned char *, unsigned int, unsigned char *, time_t);
+static int shmcb_insert_encoded_session(server_rec *, SHMCBQueue *, SHMCBCache *,
unsigned char *, unsigned int, unsigned char *, time_t);
static SSL_SESSION *shmcb_lookup_session_id(server_rec *, SHMCBQueue *, SHMCBCache *,
UCHAR *, unsigned int);
static BOOL shmcb_remove_session_id(server_rec *, SHMCBQueue *, SHMCBCache *, UCHAR
*, unsigned int);
@@ -396,14 +399,20 @@
{
SSLModConfigRec *mc = myModConfig(s);
BOOL to_return = FALSE;
+ int rv;
ssl_mutex_on(s);
- if (!shmcb_store_session(s, mc->tSessionCacheDataTable, id, idlen,
- pSession, timeout))
+ rv = shmcb_store_session(s, mc->tSessionCacheDataTable, id, idlen,
+ pSession, timeout);
+ if (rv != TRUE) {
/* in this cache engine, "stores" should never fail. */
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "'shmcb' code was unable to store a "
- "session in the cache.");
+ "'shmcb' was unable to store a session in the cache"
+ "(cause: %s)",
+ (rv == SSL_INTERNAL_ERROR) ? "internal error"
+ : (rv == SSL_SESSION_TOO_BIG) ? "session too big"
+ : "unknown error");
+ }
else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"shmcb_store successful");
@@ -648,7 +657,7 @@
return TRUE;
}
-static BOOL shmcb_store_session(
+static int shmcb_store_session(
server_rec *s, void *shm_segment, UCHAR *id,
int idlen, SSL_SESSION * pSession,
time_t timeout)
@@ -662,6 +671,7 @@
unsigned int len_encoded;
time_t expiry_time;
unsigned char *session_id = SSL_SESSION_get_session_id(pSession);
+ int rv;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"inside shmcb_store_session");
@@ -673,9 +683,9 @@
"session_id[0]=%u, masked index=%u",
session_id[0], masked_index);
if (!shmcb_get_division(header, &queue, &cache, (unsigned int)masked_index)) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"shmcb_store_session internal error");
- return FALSE;
+ return SSL_INTERNAL_ERROR;
}
/* Serialise the session, work out how much we're dealing
@@ -683,19 +693,19 @@
* or we find some assurance that it will never be necessary. */
len_encoded = i2d_SSL_SESSION(pSession, NULL);
if (len_encoded > SSL_SESSION_MAX_DER) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"session is too big (%u bytes)", len_encoded);
- return FALSE;
+ return SSL_SESSION_TOO_BIG;
}
ptr_encoded = encoded;
len_encoded = i2d_SSL_SESSION(pSession, &ptr_encoded);
expiry_time = timeout;
- if (!shmcb_insert_encoded_session(s, &queue, &cache, encoded,
- len_encoded, session_id,
- expiry_time)) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ if ((rv = shmcb_insert_encoded_session(s, &queue, &cache, encoded,
+ len_encoded, session_id,
+ expiry_time)) != TRUE) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"can't store a session!");
- return FALSE;
+ return rv;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"leaving shmcb_store successfully");
@@ -1031,7 +1041,7 @@
* event of surreal values being passed on, or ridiculously small
* cache sizes. NB: For tracing purposes, this function is also given
* the server_rec to allow "ssl_log()". */
-static BOOL shmcb_insert_encoded_session(
+static int shmcb_insert_encoded_session(
server_rec *s, SHMCBQueue * queue,
SHMCBCache * cache,
unsigned char *encoded,
@@ -1091,14 +1101,14 @@
* is verified. */
if (shmcb_get_safe_uint(cache->pos_count) + encoded_len >
header->cache_data_size) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"shmcb_insert_encoded_session internal error");
- return FALSE;
+ return SSL_INTERNAL_ERROR;
}
if (shmcb_get_safe_uint(queue->pos_count) == header->index_num) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"shmcb_insert_encoded_session internal error");
- return FALSE;
+ return SSL_INTERNAL_ERROR;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"we have %u bytes and %u indexes free - enough",
@@ -1134,9 +1144,9 @@
new_pos, new_offset);
idx = shmcb_get_index(queue, new_pos);
if (idx == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"shmcb_insert_encoded_session internal error");
- return FALSE;
+ return SSL_INTERNAL_ERROR;
}
shmcb_safe_clear(idx, sizeof(SHMCBIndex));
shmcb_set_safe_time(&(idx->expires), expiry_time);