tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r551810 - in /tomcat/connectors/trunk/jk/native/common: jk_ajp_common.c jk_lb_worker.c
Date Fri, 29 Jun 2007 06:49:28 GMT
Author: mturk
Date: Thu Jun 28 23:49:28 2007
New Revision: 551810

URL: http://svn.apache.org/viewvc?view=rev&rev=551810
Log:
Properly handle low memory situations, by checking the return values from message allocation
functions.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?view=diff&rev=551810&r1=551809&r2=551810
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Thu Jun 28 23:49:28 2007
@@ -792,7 +792,18 @@
 
     JK_TRACE_ENTER(l);
     msg = jk_b_new(&ae->pool);
-    jk_b_set_buffer_size(msg, 16);      /* 16 is way too large but I'm lazy :-) */
+    if (!msg) {
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message");
+        JK_TRACE_EXIT(l);
+        return JK_FALSE;
+    }
+    if (jk_b_set_buffer_size(msg, 16)) {
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message buffer");
+        JK_TRACE_EXIT(l);
+        return JK_FALSE;
+    }
     jk_b_reset(msg);
     jk_b_append_byte(msg, AJP13_CPING_REQUEST);
 
@@ -1212,7 +1223,7 @@
         if (err ||
             ((rc = ajp_connection_tcp_send_message(ae, op->request, l)) != JK_TRUE)) {
             if (rc != JK_FATAL_ERROR) {
-                if (err == 1) {                
+                if (err == 1) {
                     jk_log(l, JK_LOG_DEBUG,
                            "(%s) failed sending request. "
                            "Will try another pooled connection",
@@ -1222,7 +1233,7 @@
                     jk_log(l, JK_LOG_INFO,
                            "(%s) error sending request. "
                            "Will try another pooled connection",
-                            ae->worker->name);                    
+                            ae->worker->name);
                 }
                 ajp_next_connection(ae, l);
             }
@@ -1828,15 +1839,54 @@
 
     p = e->endpoint_private;
     op->request = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->request, p->worker->max_packet_size);
+    if (!op->request) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
+    if (jk_b_set_buffer_size(op->request, p->worker->max_packet_size)) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message buffer");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
     jk_b_reset(op->request);
 
     op->reply = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->reply, p->worker->max_packet_size);
+    if (!op->reply) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
+    if (jk_b_set_buffer_size(op->reply, p->worker->max_packet_size)) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message buffer");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
     jk_b_reset(op->reply);
 
     op->post = jk_b_new(&(p->pool));
-    jk_b_set_buffer_size(op->post, p->worker->max_packet_size);
+    if (!op->post) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
+    if (jk_b_set_buffer_size(op->post, p->worker->max_packet_size)) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message buffer");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;
+    }
     jk_b_reset(op->post);
 
     op->recoverable = JK_TRUE;

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?view=diff&rev=551810&r1=551809&r2=551810
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Thu Jun 28 23:49:28 2007
@@ -909,7 +909,20 @@
 
     /* set the recovery post, for LB mode */
     s->reco_buf = jk_b_new(s->pool);
-    jk_b_set_buffer_size(s->reco_buf, p->worker->max_packet_size);
+    if (!s->reco_buf) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;        
+    }
+    if (jk_b_set_buffer_size(s->reco_buf, p->worker->max_packet_size)) {
+        *is_error = JK_HTTP_SERVER_ERROR;
+        jk_log(l, JK_LOG_ERROR,
+               "Failed allocating AJP message buffer");
+        JK_TRACE_EXIT(l);
+        return JK_SERVER_ERROR;        
+    }
     jk_b_reset(s->reco_buf);
     s->reco_status = RECO_INITED;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message