From: Paul Querna Date: Sat, 28 Mar 2009 13:51:51 +0000 (+0000) Subject: - Improve flushing/connection eos logic. X-Git-Tag: 2.3.3~775 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51fa0a1acd807edf36c6c6c63e56e9be3eb994db;p=thirdparty%2Fapache%2Fhttpd.git - 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@759462 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_serf.c b/modules/proxy/mod_serf.c index 49e4cb5cd27..6c84b1769fc 100644 --- a/modules/proxy/mod_serf.c +++ b/modules/proxy/mod_serf.c @@ -72,17 +72,27 @@ static void timed_cleanup_callback(void *baton) { 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 @@ static void closed_connection(serf_connection_t *conn, { 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 @@ static serf_bucket_t* conn_setup(apr_socket_t *sock, 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 @@ static serf_bucket_t* accept_response(serf_request_t *request, 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 @@ static apr_status_t handle_response(serf_request_t *request, 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 @@ static apr_status_t handle_response(serf_request_t *request, **/ do { - apr_bucket *e; apr_brigade_cleanup(ctx->tmpbb); rv = serf_bucket_read(response, AP_IOBUFSIZE, &data, &len); @@ -298,6 +299,12 @@ static apr_status_t handle_response(serf_request_t *request, 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 @@ static apr_status_t handle_response(serf_request_t *request, 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 @@ static apr_status_t setup_request(serf_request_t *request, 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 @@ static int drive_serf(request_rec *r, serf_config_t *conf) baton); if (mpm_supprts_serf) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, baton->r, "handing off serf request to mpm"); return SUSPENDED; } else {