ASF Bugzilla – Attachment 31549 Details for
Bug 56333
API to resume a SUSPENDED connection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Testcase for new patch
mod_sustest.c (text/plain), 3.09 KB, created by
Edward Lu
on 2014-04-22 20:31:41 UTC
(
hide
)
Description:
Testcase for new patch
Filename:
MIME Type:
Creator:
Edward Lu
Created:
2014-04-22 20:31:41 UTC
Size:
3.09 KB
patch
obsolete
>// apxs -i -a -c mod_sustest.c >// SetHandler sustest >// ab -n 9999 -c 9 http://localhost/sustest > >#include <httpd.h> >#include <http_protocol.h> >#include <http_config.h> >#include <http_request.h> >#include <http_log.h> >#include <http_connection.h> >#include <ap_mpm.h> > >#include <unistd.h> > >module sustest_module; >APLOG_USE_MODULE (sustest); > >APR_DECLARE_OPTIONAL_FN(int, ap_resume_suspended, (conn_rec *)); >APR_OPTIONAL_FN_TYPE(ap_resume_suspended) *ap_resume_suspended; > >static void render (request_rec* r) { > r->content_type = "text/html; charset=utf-8"; > if (!r->header_only) { > ap_rputs ("<!doctype html><html lang=\"ru\"><head><meta charset=\"UTF-8\"><title>test</title></head><body>\n", r); > if (r->filename) ap_rprintf (r, "FS path: %s<br/>\n", r->filename); > ap_rputs ("v. 02<br/>", r); > ap_rputs ("</body></html>\n", r); > } >} > >static void setupSuspended (request_rec* r) { >} > >static void finishSuspended (request_rec* r) { > conn_rec* c = r->connection; > apr_thread_mutex_lock (r->invoke_mtx); > > if (r->connection->aborted) { > ap_die (HTTP_INTERNAL_SERVER_ERROR, r); > } else if (r->status == HTTP_OK) { > apr_bucket_brigade* bb = apr_brigade_create (r->pool, r->connection->bucket_alloc); > //APR_BRIGADE_INSERT_TAIL (bb, apr_bucket_flush_create (r->connection->bucket_alloc)); > APR_BRIGADE_INSERT_TAIL (bb, apr_bucket_eos_create (r->connection->bucket_alloc)); > ap_pass_brigade (r->output_filters, bb); > apr_brigade_destroy (bb); > ap_finalize_request_protocol (r); > } > > apr_thread_mutex_unlock (r->invoke_mtx); > ap_process_request_after_handler (r); > ap_log_rerror (APLOG_MARK, LOG_INFO, r->status, r, "Calling resume_suspended..."); > ap_mpm_resume_suspended (c); >} > >static void callback (void* vr) { > request_rec* r = (request_rec*) vr; > ap_log_rerror (APLOG_MARK, LOG_INFO, r->status, r, "Callback."); > > if (!r->connection->aborted) render (r); > > finishSuspended (r); >} > >static void* thread_func (void* vr) { > int rc; > usleep (100); > callback (vr); > return NULL; >} > >static int sustest_handler (request_rec* r) { > pthread_t thread; > int can_suspend = 0; > > if (!r->handler || strcmp (r->handler, "sustest")) return DECLINED; > if (ap_meets_conditions (r) != OK) {ap_log_rerror (APLOG_MARK, APLOG_NOTICE, 0, r, "!ap_meets_conditions"); return DECLINED;} > if (ap_mpm_query(AP_MPMQ_CAN_SUSPEND, &can_suspend) == APR_ENOTIMPL || !can_suspend) { > ap_log_rerror (APLOG_MARK, LOG_INFO, APR_ENOTIMPL, r, "MPM doesn't support suspending"); > return HTTP_INTERNAL_SERVER_ERROR; > } > > ap_log_rerror (APLOG_MARK, LOG_INFO, r->status, r, "sustest_handler"); > //render (r); return OK; > setupSuspended (r); > > if (pthread_create (&thread, NULL, thread_func, r) != 0) return DECLINED; > pthread_detach (thread); > //ap_mpm_register_timed_callback (apr_time_from_msec (90), callback, r); > return SUSPENDED; >} > >static void sustest_hooks (apr_pool_t *pool) { > ap_hook_handler (sustest_handler, NULL, NULL, APR_HOOK_FIRST); > > ap_resume_suspended = APR_RETRIEVE_OPTIONAL_FN(ap_resume_suspended); >} > >module sustest_module = { > STANDARD20_MODULE_STUFF, > NULL, > NULL, > NULL, > NULL, > NULL, > sustest_hooks >};
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 56333
:
31519
|
31520
|
31521
|
31548
| 31549 |
31551