Re: [PATCH] JK and load-balanced POSTs

2004-07-21 Thread Joel Dice
It looks like the CVS version works.  Next time I'll try CVS before trying
to fix a problem myself. :)

Looking forward to 1.2.6!


On Wed, 21 Jul 2004, Rainer Jung wrote:

> Henri Gomez wrote:
>
> >
> > Thanks to check if it works for you with the latest jk in CVS...
> >
>
> ... and I think we expect the new 1.2.6 release soon. So either wait for
> the new release - or even better: send feedback on the CVS as soon as
> possible.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [PATCH] JK and load-balanced POSTs

2004-07-21 Thread Joel Dice
Thanks for the information, Henri and Rainer.  I'll try the CVS version
today.

On Wed, 21 Jul 2004, Rainer Jung wrote:

> Henri Gomez wrote:
>
> >
> > Thanks to check if it works for you with the latest jk in CVS...
> >
>
> ... and I think we expect the new 1.2.6 release soon. So either wait for
> the new release - or even better: send feedback on the CVS as soon as
> possible.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[PATCH] JK and load-balanced POSTs

2004-07-20 Thread Joel Dice
Attached is a patch against JK 1.2.5 to fix handling of POSTs for
load-balanced workers.

The problem it addresses occurs when an endpoint fails while mod_jk is
trying to send it a POST request.  When mod_jk gives up and attempts to
use a different endpoint, the body of the POST is lost.  Since the POST is
not part of the new endpoint's state, mod_jk tries to re-read the data
from the client, but the client has nothing more to say, so the read
returns zero bytes.  This empty post is sent on to the application server,
confusing it.

The patch fixes this problem by attaching the POST data to the request
state (of type jk_ws_service_t) instead of the endpoint state (of type
ajp_endpoint_t).

Feedback is welcome.

 - JoelIndex: jk/native/common/jk_ajp_common.c
===
--- jk/native/common/jk_ajp_common.c(revision 930)
+++ jk/native/common/jk_ajp_common.c(revision 931)
@@ -966,9 +966,9 @@
 jk_log(l, JK_LOG_DEBUG,
"ajp_send_request 2: "
"request body to send %d - request body to resend %d\n", 
-   ae->left_bytes_to_send, jk_b_get_len(op->reply) - AJP_HEADER_LEN);
+   ae->left_bytes_to_send, jk_b_get_len(op->post) - AJP_HEADER_LEN);
 
-/*
+/* XXX: this comment looks outdated:
  * POST recovery job is done here.
  * It's not very fine to have posted data in reply but that's the only easy
  * way to do that for now. Sharing the reply is really a bad solution but
@@ -1217,9 +1217,18 @@
 jk_b_set_buffer_size(op->reply, DEF_BUFFER_SZ);
 jk_b_reset(op->reply); 
 
-op->post = jk_b_new(&(p->pool));
-jk_b_set_buffer_size(op->post, DEF_BUFFER_SZ);
-jk_b_reset(op->post); 
+   if (s->post == NULL) {
+ s->post = jk_b_new(s->pool);
+ if (s->post == NULL) {
+   jk_log(l, JK_LOG_ERROR, "ERROR: unable to allocate POST buffer");
+*is_recoverable_error = JK_FALSE;
+return JK_FALSE;
+ }
+ jk_b_set_buffer_size(s->post, DEF_BUFFER_SZ);
+ jk_b_reset(s->post);
+   }
+
+   op->post = s->post;
 
 op->recoverable = JK_TRUE;
 op->uploadfd = -1;  /* not yet used, later ;) */
Index: jk/native/common/jk_service.h
===
--- jk/native/common/jk_service.h   (revision 930)
+++ jk/native/common/jk_service.h   (revision 931)
@@ -72,6 +72,7 @@
 #include "jk_map.h"
 #include "jk_global.h"
 #include "jk_logger.h"
+#include "jk_msg_buff.h"
 #include "jk_pool.h"
 #include "jk_uri_worker_map.h"
 
@@ -235,8 +236,14 @@
a version that doesn't support secret - don't set the secret,
and it'll work.
  */
-char*secret;
+char*secret;
+
 /*
+ * The body of the POST, if any.
+ */
+jk_msg_buf_t *post;
+
+/*
  * Callbacks into the web server.  For each, the first argument is
  * essentially a 'this' pointer.  All return JK_TRUE on success
  * and JK_FALSE on failure.
Index: jk/native/common/jk_util.c
===
--- jk/native/common/jk_util.c  (revision 930)
+++ jk/native/common/jk_util.c  (revision 931)
@@ -926,4 +926,5 @@
 s->attributes_values= NULL;
 s->num_attributes   = 0;
 s->jvm_route= NULL;
+s->post = NULL;
 }
Index: jk/native/common/jk_msg_buff.h
===
--- jk/native/common/jk_msg_buff.h  (revision 930)
+++ jk/native/common/jk_msg_buff.h  (revision 931)
@@ -65,6 +65,7 @@
 #ifndef JK_MSG_BUF_H
 #define JK_MSG_BUF_H
 
+#include "jk_pool.h"
 
 #ifdef __cplusplus
 extern "C" {
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]