Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 94152 invoked from network); 11 Dec 2008 05:01:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2008 05:01:14 -0000 Received: (qmail 75284 invoked by uid 500); 11 Dec 2008 05:01:26 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 75182 invoked by uid 500); 11 Dec 2008 05:01:26 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 75173 invoked by uid 500); 11 Dec 2008 05:01:26 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 75170 invoked by uid 99); 11 Dec 2008 05:01:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Dec 2008 21:01:26 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2008 05:01:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8EBEA2388979; Wed, 10 Dec 2008 21:00:50 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r725576 - in /webservices/axis2/trunk/c/src/core/transport/http/server/apache2: apache2_worker.c mod_axis2.c Date: Thu, 11 Dec 2008 05:00:50 -0000 To: axis2-cvs@ws.apache.org From: manjula@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081211050050.8EBEA2388979@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: manjula Date: Wed Dec 10 21:00:50 2008 New Revision: 725576 URL: http://svn.apache.org/viewvc?rev=725576&view=rev Log: Adding fixes for httpd for Axis2C-1301. Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c webservices/axis2/trunk/c/src/core/transport/http/server/apache2/mod_axis2.c Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c?rev=725576&r1=725575&r2=725576&view=diff ============================================================================== --- webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c (original) +++ webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c Wed Dec 10 21:00:50 2008 @@ -35,22 +35,32 @@ #include #include #include +#include #define READ_SIZE 2048 static axis2_status_t apache2_worker_send_mtom_message( request_rec *request, const axutil_env_t * env, - axutil_array_list_t *mime_parts); + axutil_array_list_t *mime_parts, + axis2_char_t *mtom_sending_callback_name); static axis2_status_t -apache2_worker_send_attachment( +apache2_worker_send_attachment_using_file( const axutil_env_t * env, request_rec *request, FILE *fp, axis2_byte_t *buffer, int buffer_size); +static axis2_status_t +apache2_worker_send_attachment_using_callback( + const axutil_env_t * env, + request_rec *request, + axiom_mtom_sending_callback_t *callback, + void *handler, + void *user_param); + struct axis2_apache2_worker { @@ -190,6 +200,10 @@ axis2_char_t *content_language_header_value = NULL; axis2_bool_t do_mtom = AXIS2_FALSE; axutil_array_list_t *mime_parts = NULL; + axutil_param_t *callback_name_param = NULL; + axis2_char_t *mtom_sending_callback_name = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE); AXIS2_PARAM_CHECK(env->error, request, AXIS2_CRITICAL_FAILURE); @@ -1187,6 +1201,13 @@ { return AXIS2_FAILURE; } + callback_name_param = axis2_msg_ctx_get_parameter(msg_ctx, env , + AXIS2_MTOM_SENDING_CALLBACK); + if(callback_name_param) + { + mtom_sending_callback_name = + (axis2_char_t *) axutil_param_get_value (callback_name_param, env); + } } if (out_msg_ctx) @@ -1225,7 +1246,26 @@ if(do_mtom) { axis2_status_t mtom_status = AXIS2_FAILURE; - mtom_status = apache2_worker_send_mtom_message(request, env, mime_parts); + + if(!mtom_sending_callback_name) + { + /* If the callback name is not there, then we will check whether there + * is any mime_parts which has type callback. If we found then no point + * of continuing we should return a failure */ + + if(!mtom_sending_callback_name) + { + if(axis2_http_transport_utils_is_callback_required( + env, mime_parts)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Sender callback not specified"); + return AXIS2_FAILURE; + } + } + } + + mtom_status = apache2_worker_send_mtom_message(request, env, mime_parts, + mtom_sending_callback_name); if(mtom_status == AXIS2_SUCCESS) { send_status = DONE; @@ -1307,7 +1347,8 @@ static axis2_status_t apache2_worker_send_mtom_message( request_rec *request, const axutil_env_t * env, - axutil_array_list_t *mime_parts) + axutil_array_list_t *mime_parts, + axis2_char_t *mtom_sending_callback_name) { int i = 0; axiom_mime_part_t *mime_part = NULL; @@ -1360,13 +1401,42 @@ (output_buffer_size + 1) * sizeof(axis2_char_t)); - status = apache2_worker_send_attachment(env, request, + status = apache2_worker_send_attachment_using_file(env, request, f, output_buffer, output_buffer_size); if(status == AXIS2_FAILURE) { return status; } } + else if((mime_part->type) == AXIOM_MIME_PART_CALLBACK) + { + void *handler = NULL; + axiom_mtom_sending_callback_t *callback = NULL; + + handler = axis2_http_transport_utils_initiate_callback(env, + mtom_sending_callback_name, mime_part->user_param, &callback); + + if(handler) + { + status = apache2_worker_send_attachment_using_callback(env, + request, callback, handler, mime_part->user_param); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MTOM Sending Callback loading failed"); + status = AXIS2_FAILURE; + } + if(callback) + { + AXIOM_MTOM_SENDING_CALLBACK_FREE(callback, env); + callback = NULL; + } + + if(status == AXIS2_FAILURE) + { + return status; + } + } else { return AXIS2_FAILURE; @@ -1386,7 +1456,7 @@ static axis2_status_t -apache2_worker_send_attachment( +apache2_worker_send_attachment_using_file( const axutil_env_t * env, request_rec *request, FILE *fp, @@ -1455,3 +1525,41 @@ buffer = NULL; return AXIS2_SUCCESS; } + +static axis2_status_t +apache2_worker_send_attachment_using_callback( + const axutil_env_t * env, + request_rec *request, + axiom_mtom_sending_callback_t *callback, + void *handler, + void *user_param) +{ + int count = 0; + int len = 0; + axis2_status_t status = AXIS2_SUCCESS; + axis2_char_t *buffer = NULL; + + /* Keep on loading the data in a loop until + * all the data is sent */ + + while((count = AXIOM_MTOM_SENDING_CALLBACK_LOAD_DATA(callback, env, handler, &buffer)) > 0) + { + len = 0; + len = ap_rwrite(buffer, count, request); + ap_rflush(request); + if(len == -1) + { + status = AXIS2_FAILURE; + break; + } + } + + if (status == AXIS2_FAILURE) + { + AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler); + return status; + } + + status = AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler); + return status; +} Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/mod_axis2.c URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/apache2/mod_axis2.c?rev=725576&r1=725575&r2=725576&view=diff ============================================================================== --- webservices/axis2/trunk/c/src/core/transport/http/server/apache2/mod_axis2.c (original) +++ webservices/axis2/trunk/c/src/core/transport/http/server/apache2/mod_axis2.c Wed Dec 10 21:00:50 2008 @@ -320,10 +320,14 @@ axutil_allocator_t *allocator = NULL; axutil_error_t *error = NULL; + apr_allocator_t *local_allocator = NULL; + apr_pool_t *local_pool = NULL; + if (strcmp(req->handler, "axis2_module")) { return DECLINED; } + /* Set up the read policy from the client. */ if ((rv = ap_setup_client_block(req, REQUEST_CHUNKED_DECHUNK)) != OK) { @@ -331,6 +335,10 @@ } ap_should_client_block(req); + apr_allocator_create(&local_allocator); + apr_pool_create_ex(&local_pool, NULL, NULL, local_allocator); + + /*thread_env = axutil_init_thread_env(axutil_env);*/ @@ -338,8 +346,12 @@ rv = AXIS2_APACHE2_WORKER_PROCESS_REQUEST(axis2_worker, axutil_env, req);*/ /* create new allocator for this request */ - allocator = (axutil_allocator_t *) apr_palloc(req->pool, + /*allocator = (axutil_allocator_t *) apr_palloc(req->pool, + sizeof(axutil_allocator_t));*/ + + allocator = (axutil_allocator_t *) apr_palloc(local_pool, sizeof(axutil_allocator_t)); + if (!allocator) { return HTTP_INTERNAL_SERVER_ERROR; @@ -347,8 +359,8 @@ allocator->malloc_fn = axis2_module_malloc; allocator->realloc = axis2_module_realloc; allocator->free_fn = axis2_module_free; - allocator->local_pool = (void *)req->pool ; - allocator->current_pool = (void *)req->pool; + allocator->local_pool = (void *)local_pool; + allocator->current_pool = (void *)local_pool; allocator->global_pool = axutil_env->allocator->global_pool; error = axutil_error_create(allocator); @@ -364,6 +376,10 @@ return HTTP_INTERNAL_SERVER_ERROR; } + apr_pool_destroy(local_pool); + apr_allocator_destroy(local_allocator); + + return rv; }