@@ -114,6 +114,7 @@ typedef struct isapi_dir_conf {
114114 int log_unsupported ;
115115 int log_to_errlog ;
116116 int log_to_query ;
117+ int fake_async ;
117118} isapi_dir_conf ;
118119
119120typedef struct isapi_loaded isapi_loaded ;
@@ -129,6 +130,7 @@ static void *create_isapi_dir_config(apr_pool_t *p, char *dummy)
129130 dir -> log_unsupported = ISAPI_UNDEF ;
130131 dir -> log_to_errlog = ISAPI_UNDEF ;
131132 dir -> log_to_query = ISAPI_UNDEF ;
133+ dir -> fake_async = ISAPI_UNDEF ;
132134
133135 return dir ;
134136}
@@ -148,9 +150,12 @@ static void *merge_isapi_dir_configs(apr_pool_t *p, void *base_, void *add_)
148150 dir -> log_to_errlog = (add -> log_to_errlog == ISAPI_UNDEF )
149151 ? base -> log_to_errlog
150152 : add -> log_to_errlog ;
151- dir -> log_to_query = (add -> log_to_query == ISAPI_UNDEF )
153+ dir -> log_to_query = (add -> log_to_query == ISAPI_UNDEF )
152154 ? base -> log_to_query
153155 : add -> log_to_query ;
156+ dir -> fake_async = (add -> fake_async == ISAPI_UNDEF )
157+ ? base -> fake_async
158+ : add -> fake_async ;
154159
155160 return dir ;
156161}
@@ -203,16 +208,24 @@ static const char *isapi_cmd_cachefile(cmd_parms *cmd, void *dummy,
203208static const command_rec isapi_cmds [] = {
204209 AP_INIT_TAKE1 ("ISAPIReadAheadBuffer" , ap_set_int_slot ,
205210 (void * ) APR_XtOffsetOf (isapi_dir_conf , read_ahead_buflen ),
206- OR_FILEINFO , "Maximum bytes to initially pass to the ISAPI handler" ),
211+ OR_FILEINFO , "Maximum client request body to initially pass to the"
212+ " ISAPI handler (default: 48192)" ),
207213 AP_INIT_FLAG ("ISAPILogNotSupported" , ap_set_int_slot ,
208214 (void * ) APR_XtOffsetOf (isapi_dir_conf , log_unsupported ),
209- OR_FILEINFO , "Log requests not supported by the ISAPI server" ),
215+ OR_FILEINFO , "Log requests not supported by the ISAPI server"
216+ " on or off (default: off)" ),
210217 AP_INIT_FLAG ("ISAPIAppendLogToErrors" , ap_set_flag_slot ,
211218 (void * ) APR_XtOffsetOf (isapi_dir_conf , log_to_errlog ),
212- OR_FILEINFO , "Send all Append Log requests to the error log" ),
219+ OR_FILEINFO , "Send all Append Log requests to the error log"
220+ " on or off (default: off)" ),
213221 AP_INIT_FLAG ("ISAPIAppendLogToQuery" , ap_set_flag_slot ,
214222 (void * ) APR_XtOffsetOf (isapi_dir_conf , log_to_query ),
215- OR_FILEINFO , "Append Log requests are concatinated to the query args" ),
223+ OR_FILEINFO , "Append Log requests are concatinated to the query args"
224+ " on or off (default: on)" ),
225+ AP_INIT_FLAG ("ISAPIFakeAsync" , ap_set_flag_slot ,
226+ (void * ) APR_XtOffsetOf (isapi_dir_conf , fake_async ),
227+ OR_FILEINFO , "Fake Asynchronous support for isapi callbacks"
228+ " on or off [Experimental] (default: off)" ),
216229 AP_INIT_ITERATE ("ISAPICacheFile" , isapi_cmd_cachefile , NULL ,
217230 RSRC_CONF , "Cache the specified ISAPI extension in-process" ),
218231 {NULL }
@@ -240,13 +253,10 @@ struct isapi_loaded {
240253 apr_dso_handle_t * handle ;
241254 HSE_VERSION_INFO * isapi_version ;
242255 apr_uint32_t report_version ;
256+ apr_uint32_t timeout ;
243257 PFN_GETEXTENSIONVERSION GetExtensionVersion ;
244258 PFN_HTTPEXTENSIONPROC HttpExtensionProc ;
245259 PFN_TERMINATEEXTENSION TerminateExtension ;
246- #ifdef FAKE_ASYNC
247- int fakeasync ;
248- apr_uint32_t timeout ;
249- #endif
250260};
251261
252262static apr_status_t isapi_unload (isapi_loaded * isa , int force )
@@ -298,10 +308,7 @@ static apr_status_t isapi_load(apr_pool_t *p, server_rec *s, request_rec *r, isa
298308 * location, etc) they apply to.
299309 */
300310 isa -> report_version = MAKELONG (0 , 5 ); /* Revision 5.0 */
301- #ifdef FAKE_ASYNC
302311 isa -> timeout = INFINITE ; /* microsecs */
303- isa -> fakeasync = 1 ;
304- #endif
305312
306313 rv = apr_dso_load (& isa -> handle , isa -> filename , p );
307314 if (rv )
@@ -514,11 +521,9 @@ typedef struct isapi_cid {
514521 isapi_loaded * isa ;
515522 request_rec * r ;
516523 int headers_sent ;
517- #ifdef FAKE_ASYNC
518524 PFN_HSE_IO_COMPLETION completion ;
519525 void * completion_arg ;
520526 apr_thread_mutex_t * completed ;
521- #endif
522527} isapi_cid ;
523528
524529int APR_THREAD_FUNC GetServerVariable (isapi_cid * cid ,
@@ -638,7 +643,6 @@ int APR_THREAD_FUNC WriteClient(isapi_cid *cid,
638643 APR_BRIGADE_INSERT_TAIL (bb , b );
639644 rv = ap_pass_brigade (r -> output_filters , bb );
640645
641- #ifdef FAKE_ASYNC
642646 if ((flags & HSE_IO_ASYNC ) && cid -> completion ) {
643647 if (rv == OK ) {
644648 cid -> completion (cid -> ecb , cid -> completion_arg ,
@@ -649,7 +653,6 @@ int APR_THREAD_FUNC WriteClient(isapi_cid *cid,
649653 * buf_size , ERROR_WRITE_FAULT );
650654 }
651655 }
652- #endif
653656 return (rv == OK );
654657}
655658
@@ -711,7 +714,7 @@ static apr_ssize_t send_response_header(isapi_cid *cid,
711714 statlen = strlen (stat );
712715 }
713716 else {
714- char * flip = head ;
717+ const char * flip = head ;
715718 head = stat ;
716719 stat = flip ;
717720 headlen -= statlen ;
@@ -868,11 +871,9 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
868871 /* Signal to resume the thread completing this request,
869872 * leave it to the pool cleanup to dispose of our mutex.
870873 */
871- #ifdef FAKE_ASYNC
872874 if (cid -> completed ) {
873875 apr_thread_mutex_unlock (cid -> completed );
874876 }
875- #endif
876877 return 1 ;
877878
878879 case HSE_REQ_MAP_URL_TO_PATH :
@@ -928,13 +929,11 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
928929 * Per MS docs... HSE_REQ_IO_COMPLETION replaces any prior call
929930 * to HSE_REQ_IO_COMPLETION, and buf_data may be set to NULL.
930931 */
931- #ifdef FAKE_ASYNC
932- if (cid -> isa -> fakeasync ) {
932+ if (cid -> dconf .fake_async ) {
933933 cid -> completion = (PFN_HSE_IO_COMPLETION ) buf_data ;
934934 cid -> completion_arg = (void * ) data_type ;
935935 return 1 ;
936936 }
937- #endif
938937 if (cid -> dconf .log_unsupported )
939938 ap_log_rerror (APLOG_MARK , APLOG_NOERRNO |APLOG_WARNING , 0 , r ,
940939 "ISAPI: ServerSupportFunction HSE_REQ_IO_COMPLETION "
@@ -944,6 +943,8 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
944943
945944 case HSE_REQ_TRANSMIT_FILE :
946945 {
946+ /* we do nothing with (tf->dwFlags & HSE_DISCONNECT_AFTER_SEND)
947+ */
947948 HSE_TF_INFO * tf = (HSE_TF_INFO * )buf_data ;
948949 apr_uint32_t sent = 0 ;
949950 apr_ssize_t ate = 0 ;
@@ -953,11 +954,7 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
953954 apr_file_t * fd ;
954955 apr_off_t fsize ;
955956
956- #ifdef FAKE_ASYNC
957- if (!cid -> isa -> fakeasync )
958- #endif
959- if (tf -> dwFlags & HSE_IO_ASYNC )
960- {
957+ if (!cid -> dconf .fake_async && (tf -> dwFlags & HSE_IO_ASYNC )) {
961958 if (cid -> dconf .log_unsupported )
962959 ap_log_rerror (APLOG_MARK , APLOG_NOERRNO |APLOG_WARNING , 0 , r ,
963960 "ISAPI: ServerSupportFunction HSE_REQ_TRANSMIT_FILE "
@@ -1053,13 +1050,9 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
10531050 APR_BRIGADE_INSERT_TAIL (bb , b );
10541051 ap_pass_brigade (r -> output_filters , bb );
10551052
1056- /* we do nothing with (tf->dwFlags & HSE_DISCONNECT_AFTER_SEND)
1053+ /* Use tf->pfnHseIO + tf->pContext, or if NULL, then use cid->fnIOComplete
1054+ * pass pContect to the HseIO callback.
10571055 */
1058-
1059- #ifdef FAKE_ASYNC
1060- /* Use tf->pfnHseIO + tf->pContext, or if NULL, then use cid->fnIOComplete
1061- * pass pContect to the HseIO callback.
1062- */
10631056 if (tf -> dwFlags & HSE_IO_ASYNC ) {
10641057 if (tf -> pfnHseIO ) {
10651058 if (rv == OK ) {
@@ -1082,7 +1075,6 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
10821075 }
10831076 }
10841077 }
1085- #endif
10861078 return (rv == OK );
10871079 }
10881080
@@ -1102,11 +1094,8 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
11021094 case HSE_REQ_ASYNC_READ_CLIENT :
11031095 {
11041096 apr_uint32_t read = 0 ;
1105- #ifdef FAKE_ASYNC
11061097 int res ;
1107- if (!cid -> isa -> fakeasync )
1108- #endif
1109- {
1098+ if (!cid -> dconf .fake_async ) {
11101099 if (cid -> dconf .log_unsupported )
11111100 ap_log_rerror (APLOG_MARK , APLOG_NOERRNO |APLOG_WARNING , 0 , r ,
11121101 "ISAPI: asynchronous I/O not supported: %s" ,
@@ -1115,7 +1104,6 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
11151104 return 0 ;
11161105 }
11171106
1118- #ifdef FAKE_ASYNC
11191107 if (r -> remaining < * buf_size ) {
11201108 * buf_size = (apr_size_t )r -> remaining ;
11211109 }
@@ -1137,7 +1125,6 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
11371125 }
11381126 }
11391127 return (res >= 0 );
1140- #endif
11411128 }
11421129
11431130 case HSE_REQ_GET_IMPERSONATION_TOKEN : /* Added in ISAPI 4.0 */
@@ -1373,9 +1360,11 @@ apr_status_t isapi_handler (request_rec *r)
13731360 cid -> dconf .log_unsupported = (dconf -> log_unsupported == ISAPI_UNDEF )
13741361 ? 0 : dconf -> log_unsupported ;
13751362 cid -> dconf .log_to_errlog = (dconf -> log_to_errlog == ISAPI_UNDEF )
1376- ? 1 : dconf -> log_to_errlog ;
1363+ ? 0 : dconf -> log_to_errlog ;
13771364 cid -> dconf .log_to_query = (dconf -> log_to_query == ISAPI_UNDEF )
13781365 ? 1 : dconf -> log_to_query ;
1366+ cid -> dconf .fake_async = (dconf -> fake_async == ISAPI_UNDEF )
1367+ ? 0 : dconf -> fake_async ;
13791368
13801369 cid -> ecb = apr_pcalloc (r -> pool , sizeof (EXTENSION_CONTROL_BLOCK ));
13811370 cid -> ecb -> ConnID = cid ;
@@ -1483,7 +1472,6 @@ apr_status_t isapi_handler (request_rec *r)
14831472 break ;
14841473
14851474 case HSE_STATUS_PENDING :
1486- #ifdef FAKE_ASYNC
14871475 /* emulating async behavior...
14881476 *
14891477 * Create a cid->completed mutex and wait on it for some timeout
@@ -1495,8 +1483,7 @@ apr_status_t isapi_handler (request_rec *r)
14951483 * This request completes upon a notification through
14961484 * ServerSupportFunction(HSE_REQ_DONE_WITH_SESSION)
14971485 */
1498- if (isa -> fakeasync )
1499- {
1486+ if (cid -> dconf .fake_async ) {
15001487 apr_thread_mutex_t * comp ;
15011488
15021489 rv = apr_thread_mutex_create (& cid -> completed ,
@@ -1514,10 +1501,7 @@ apr_status_t isapi_handler (request_rec *r)
15141501 }
15151502 break ;
15161503 }
1517- else
1518- #endif
1519- if (cid -> dconf .log_unsupported )
1520- {
1504+ else if (cid -> dconf .log_unsupported ) {
15211505 ap_log_rerror (APLOG_MARK , APLOG_NOERRNO |APLOG_WARNING , 0 , r ,
15221506 "ISAPI: asynch I/O result HSE_STATUS_PENDING "
15231507 "from HttpExtensionProc() is not supported: %s" ,
0 commit comments