You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2009/03/28 14:51:51 UTC

svn commit: r759462 - /httpd/httpd/trunk/modules/proxy/mod_serf.c

Author: pquerna
Date: Sat Mar 28 13:51:51 2009
New Revision: 759462

URL: http://svn.apache.org/viewvc?rev=759462&view=rev
Log:
- Improve flushing/connection eos logic.
- Use brigade_write instead of immortal buckets that aren't immortal.
- Read HTTP status code from serf.
- Remove extra logging.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_serf.c

Modified: httpd/httpd/trunk/modules/proxy/mod_serf.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_serf.c?rev=759462&r1=759461&r2=759462&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_serf.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_serf.c Sat Mar 28 13:51:51 2009
@@ -72,17 +72,27 @@
 {
     s_baton_t *ctx = baton;
     
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: timed_cleanup_callback");
-
     /* Causes all serf connections to unregister from the event mpm */
-    apr_pool_destroy(ctx->serf_pool);
     if (ctx->rstatus) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, ctx->rstatus, ctx->r,
                       "serf: request returned: %d", ctx->rstatus);
         ctx->r->status = HTTP_OK;
+        apr_pool_destroy(ctx->serf_pool);
         ap_die(ctx->rstatus, ctx->r);
     }
     else {
+        apr_bucket *e;
+        apr_brigade_cleanup(ctx->tmpbb);
+        e = apr_bucket_flush_create(ctx->r->connection->bucket_alloc);
+        APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e);
+        e = apr_bucket_eos_create(ctx->r->connection->bucket_alloc);
+        APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e);
+
+        /* TODO: return code? bleh */
+        ap_pass_brigade(ctx->r->output_filters, ctx->tmpbb);
+        
+        apr_pool_destroy(ctx->serf_pool);
+
         ap_finalize_request_protocol(ctx->r);
         ap_process_request_after_handler(ctx->r);
         return;
@@ -96,8 +106,6 @@
 {
     s_baton_t *ctx = closed_baton;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: closed_connection");
-
     if (why) {
         /* justin says that error handling isn't done yet. hah. */
         /* XXXXXX: review */
@@ -118,8 +126,6 @@
     serf_bucket_t *c;
     s_baton_t *ctx = setup_baton;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: conn_setup ");
-
     c = serf_bucket_socket_create(sock, ctx->bkt_alloc);
     if (ctx->want_ssl) {
         c = serf_bucket_ssl_decrypt_create(c, ctx->ssl_ctx, ctx->bkt_alloc);
@@ -238,8 +244,6 @@
     serf_bucket_t *c;
     serf_bucket_alloc_t *bkt_alloc;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: accept_response");
-
     /* get the per-request bucket allocator */
     bkt_alloc = serf_request_get_alloc(request);
 
@@ -260,8 +264,6 @@
     apr_size_t len;
     serf_status_line sl;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: handle_response");
-
     /* XXXXXXX: Create better error message. */
     rv = serf_bucket_response_status(response, &sl);
     if (rv) {
@@ -287,7 +289,6 @@
      **/
 
     do {
-        apr_bucket *e;
         apr_brigade_cleanup(ctx->tmpbb);
         rv = serf_bucket_read(response, AP_IOBUFSIZE, &data, &len);
 
@@ -298,6 +299,12 @@
 
         if (!ctx->done_headers) {
             serf_bucket_t *hdrs;
+            serf_status_line line;
+
+            /* TODO: improve */
+            serf_bucket_response_status(response, &line);
+            ctx->r->status = line.code;
+            
             hdrs = serf_bucket_response_get_headers(response);
             serf_bucket_headers_do(hdrs, copy_headers_out, ctx);
             ctx->done_headers = 1;
@@ -306,16 +313,11 @@
 
         if (len > 0) {
             /* TODO: make APR bucket <-> serf bucket stuff more magical. */
-            e = apr_bucket_immortal_create(data, len, ctx->r->connection->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e);
+            apr_brigade_write(ctx->tmpbb, NULL, NULL, data, len);
         }
 
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: writing %"APR_SIZE_T_FMT" bytes", len);
-
         if (APR_STATUS_IS_EOF(rv)) {
             ctx->keep_reading = 0;
-            e = apr_bucket_flush_create(ctx->r->connection->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e);
 
             ctx->rstatus = ap_pass_brigade(ctx->r->output_filters, ctx->tmpbb);
 
@@ -350,8 +352,6 @@
     serf_bucket_t *hdrs_bkt;
     serf_bucket_t *body_bkt = NULL;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->r, "serf: setup_request");
-
     /* XXXXX: handle incoming request bodies */
     *req_bkt = serf_bucket_request_create(ctx->r->method, ctx->r->unparsed_uri, body_bkt,
                                           serf_request_get_alloc(request));
@@ -525,7 +525,6 @@
                                               baton);
 
     if (mpm_supprts_serf) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, baton->r, "handing off serf request to mpm");
         return SUSPENDED;
     }
     else {