This is an automated email from the ASF dual-hosted git repository. mxmanghi pushed a commit to branch quattuor in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
The following commit(s) were added to refs/heads/quattuor by this push: new c7f3296 Thoroughly removed trailing whitespaces from C code c7f3296 is described below commit c7f32967a88cb9fbf65ec9a6fbc7228ab518b52f Author: Massimo Manghi <mxman...@apache.org> AuthorDate: Tue Nov 29 19:03:35 2022 +0100 Thoroughly removed trailing whitespaces from C code --- ChangeLog | 3 + src/TclWeb.h | 2 +- src/librivet/rivetCrypt.c | 2 +- src/librivet/rivetList.c | 20 ++--- src/librivet/rivetPkgInit.c | 18 ++-- src/librivet/rivetWWW.c | 2 +- src/mod_rivet_ng/TclWebapache.c | 58 ++++++------- src/mod_rivet_ng/apache_config.c | 80 ++++++++--------- src/mod_rivet_ng/mod_rivet.c | 66 +++++++------- src/mod_rivet_ng/mod_rivet.h | 16 ++-- src/mod_rivet_ng/mod_rivet_cache.c | 22 ++--- src/mod_rivet_ng/mod_rivet_cache.h | 2 +- src/mod_rivet_ng/mod_rivet_common.c | 142 +++++++++++++++---------------- src/mod_rivet_ng/mod_rivet_common.h | 2 +- src/mod_rivet_ng/mod_rivet_generator.c | 46 +++++----- src/mod_rivet_ng/rivetChannel.c | 2 +- src/mod_rivet_ng/rivetCore.c | 122 +++++++++++++------------- src/mod_rivet_ng/rivetInspect.c | 58 ++++++------- src/mod_rivet_ng/rivet_lazy_mpm.c | 104 +++++++++++----------- src/mod_rivet_ng/rivet_prefork_mpm.c | 42 ++++----- src/mod_rivet_ng/rivet_types.h | 2 +- src/mod_rivet_ng/rivet_worker_mpm.c | 110 ++++++++++++------------ src/mod_rivet_ng/worker_prefork_common.c | 38 ++++----- src/mod_rivet_ng/worker_prefork_common.h | 2 +- src/parser/parserPkgInit.c | 8 +- src/parser/rivetParser.c | 6 +- src/request/apache_multipart_buffer.c | 6 +- src/request/apache_multipart_buffer.h | 4 +- src/request/apache_request.c | 16 ++-- src/request/apache_request.h | 4 +- src/rivet.h | 12 +-- 31 files changed, 510 insertions(+), 507 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54f05bb..dc04620 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2022-11-29 Massimo Manghi <mxman...@apache.org> + * src/: thoroughly removed trailing spaces from C code + 2022-06-10 Massimo Manghi <mxman...@apache.org> * doc/xml/directives.xml: moved misplaced text in table * configure.ac: Changed default for HonorHeadRequests to 'yes' diff --git a/src/TclWeb.h b/src/TclWeb.h index 0de1ba9..d22305c 100644 --- a/src/TclWeb.h +++ b/src/TclWeb.h @@ -188,7 +188,7 @@ int TclWeb_UploadSave(char *varname, Tcl_Obj *filename, TclWebRequest *req); * TclWeb_UploadData -- * * Returns the uploaded data to the Tcl script level. - * + * * If the config parameter upload_files_to_var is not set the procedure * returs an error * diff --git a/src/librivet/rivetCrypt.c b/src/librivet/rivetCrypt.c index 7c9474c..78e2918 100644 --- a/src/librivet/rivetCrypt.c +++ b/src/librivet/rivetCrypt.c @@ -184,7 +184,7 @@ Rivet_InitCrypt( Tcl_Interp *interp) RIVET_EXPORT_CMD(interp,rivet_ns,"encrypt"); RIVET_EXPORT_CMD(interp,rivet_ns,"decrypt"); - RIVET_EXPORT_CMD(interp,rivet_ns,"crypt"); + RIVET_EXPORT_CMD(interp,rivet_ns,"crypt"); } #endif return TCL_OK; diff --git a/src/librivet/rivetList.c b/src/librivet/rivetList.c index 5884756..3aabd2b 100644 --- a/src/librivet/rivetList.c +++ b/src/librivet/rivetList.c @@ -277,7 +277,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) c = *next; /* if we've got a quote at this point, it is at the start - * of a field, scan to the closing quote, make that a field, + * of a field, scan to the closing quote, make that a field, * and update */ if (c == '"') { @@ -290,7 +290,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) if (c == '\0') goto format_error; /* - * If we get a double quote, first see if it's a pair of double + * If we get a double quote, first see if it's a pair of double * quotes, i.e. a quoted quote, and handle that. */ if (c == '"') { @@ -309,7 +309,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) next++; continue; } - /* It's a solo double-quote, not a pair of double-quotes, + /* It's a solo double-quote, not a pair of double-quotes, * so terminate the element * at the current quote (the closing quote). */ @@ -322,7 +322,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) ++next; c = *next; - /* + /* * if we get end-of-line here, it's fine... and we're done */ @@ -336,7 +336,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) format_error: Tcl_ResetResult (interp); Tcl_AppendResult (interp, - "format error in string: \"", + "format error in string: \"", first, "\"", (char *) NULL); return TCL_ERROR; } @@ -362,7 +362,7 @@ Rivet_CommaSplitObjCmd (notUsed, interp, objc, objv) c = *next; /* If we reach end of the string, append the last element - * and return to our caller. + * and return to our caller. */ if (c == '\0') { @@ -427,9 +427,9 @@ Rivet_CommaJoinObjCmd (notUsed, interp, objc, objv) resultPtr = Tcl_GetObjResult (interp); - if (Tcl_ListObjGetElements (interp, - objv[1], - &listObjc, + if (Tcl_ListObjGetElements (interp, + objv[1], + &listObjc, &listObjv) != TCL_OK) { return TCL_ERROR; } @@ -547,7 +547,7 @@ TCL_CMD_HEADER( Rivet_LassignArrayObjCmd ) extern Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp); #endif -int +int Rivet_InitList( Tcl_Interp *interp) { RIVET_OBJ_CMD("lremove",Rivet_LremoveObjCmd,NULL); diff --git a/src/librivet/rivetPkgInit.c b/src/librivet/rivetPkgInit.c index 17fd31e..a996cfc 100644 --- a/src/librivet/rivetPkgInit.c +++ b/src/librivet/rivetPkgInit.c @@ -40,7 +40,7 @@ * pointer is stored in the interpreter's associated data (pointing to a * rivet_interp_globals structure) if the interpreter is passed by mod_rivet. * Otherwise a new ::rivet namespace is created and its Tcl_Namespace - * pointer is returned + * pointer is returned * * Parameters: * @@ -55,13 +55,13 @@ #if RIVET_NAMESPACE_EXPORT == 1 -Tcl_Namespace* +Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp) { Tcl_Namespace *rivet_ns; rivet_ns = Tcl_FindNamespace(interp,RIVET_NS,NULL,TCL_GLOBAL_ONLY); - if (rivet_ns == NULL) + if (rivet_ns == NULL) { rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,NULL, (Tcl_NamespaceDeleteProc *)NULL); @@ -88,10 +88,10 @@ Rivetlib_Init( Tcl_Interp *interp ) { #ifdef USE_TCL_STUBS - if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { #else - if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { -#endif + if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { +#endif return TCL_ERROR; } @@ -120,10 +120,10 @@ Rivetlib_SafeInit( Tcl_Interp *interp ) { #ifdef USE_TCL_STUBS - if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { #else - if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { -#endif + if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { +#endif return TCL_ERROR; } diff --git a/src/librivet/rivetWWW.c b/src/librivet/rivetWWW.c index 48ea2c0..c62dcb5 100644 --- a/src/librivet/rivetWWW.c +++ b/src/librivet/rivetWWW.c @@ -361,7 +361,7 @@ TCL_CMD_HEADER( Rivet_EscapeShellCommandCmd ) extern Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp); #endif -int +int Rivet_InitWWW( Tcl_Interp *interp) { RIVET_OBJ_CMD ("unescape_string",Rivet_UnescapeStringCmd,NULL); diff --git a/src/mod_rivet_ng/TclWebapache.c b/src/mod_rivet_ng/TclWebapache.c index 77838eb..b01a137 100644 --- a/src/mod_rivet_ng/TclWebapache.c +++ b/src/mod_rivet_ng/TclWebapache.c @@ -65,7 +65,7 @@ extern mod_rivet_globals* module_globals; if (source == VAR_SRC_QUERYSTRING) { j = nargs; } \ else if (source == VAR_SRC_POST) { i = nargs; } -/* +/* * -- TclWeb_NewRequestObject * * @@ -98,7 +98,7 @@ TclWeb_NewRequestObject (apr_pool_t *p) * TclWebRequest* req: a pointer to a TclWebRequest object to be intialized * Tcl_Interp* interp: current Tcl_Interp object serving the request * void* arg: generic pointer. Current implementation passes the - * request_rec object pointer + * request_rec object pointer * */ @@ -126,11 +126,11 @@ TclWeb_InitRequest(rivet_thread_private* private, Tcl_Interp *interp) if (((private->ctype==RIVET_TEMPLATE) && (content_type_len > strlen(RIVET_TEMPLATE_CTYPE))) || \ ((private->ctype==RIVET_TCLFILE) && (content_type_len > strlen(RIVET_TCLFILE_CTYPE)))) { - + char* charset; /* we parse the content type: we are after a 'charset' parameter definition */ - + charset = strstr(r->content_type,"charset"); if (charset != NULL) { charset = apr_pstrdup(r->pool,charset); @@ -149,7 +149,7 @@ INLINE int TclWeb_SendHeaders(TclWebRequest *req) { //TODO: fix ap_send_http_header - + ap_send_http_header(req->req); return TCL_OK; @@ -167,7 +167,7 @@ TclWeb_StopSending(TclWebRequest *req) int TclWeb_SetHeaderType(char *header, TclWebRequest *req) { - + if (req->headers_set) return TCL_ERROR; @@ -193,12 +193,12 @@ TclWeb_PrintHeaders(TclWebRequest *req) { TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, req); } - + /* * seems that ap_send_http_header is redefined to ; in Apache2.2 * ap_send_http_header(req->req); */ - + TclWeb_SendHeaders(req); req->headers_printed = 1; @@ -245,11 +245,11 @@ TclWeb_HeaderSet(char *header, char *val, TclWebRequest *req) * headers * - it returns nothing since it's a wrapper around an APR call * that doesn't return anything - * - * -- TclWeb_OutputHeaderGet: reads from the output headers and + * + * -- TclWeb_OutputHeaderGet: reads from the output headers and * returns the value associated to a key. If the key is not * existing it returns NULL - * + * */ INLINE void @@ -461,11 +461,11 @@ TclWeb_VarNumber(Tcl_Obj *result, int source, TclWebRequest *req) /* Environment variables. Include variables handling */ -/* These 2 array must be aligned and a one-to-one correspondence preserved +/* These 2 array must be aligned and a one-to-one correspondence preserved * The enum include_vars_idx *must* be terminated by 'invalid_env_var' - * Adding a new env variable requires + * Adding a new env variable requires * + the name of the variable be listed in include_env_vars - * + a new value in the enumerator include_vars_idx must be added in the + * + a new value in the enumerator include_vars_idx must be added in the * corresponding position * + the switch construct in function TclWeb_SelectEnvIncludeVar must * be expanded to handle the new case identified by the new enumerator value @@ -483,11 +483,11 @@ enum include_vars_idx { invalid_env_var }; -/* -- TclWeb_SelectEnvIncludeVar +/* -- TclWeb_SelectEnvIncludeVar * * Depending on the value idx of the enumerator a method is selected * to return a string of a specific environment variable methods - * Adding new environment variables need new cases of the switch + * Adding new environment variables need new cases of the switch * construct to be added, provided the data can be obtained from * the rivet_thread_private structure * @@ -501,7 +501,7 @@ enum include_vars_idx { * A character string pointer to the value of the environment variable or * NULL if the enumerator value idx was invalid or resolving the environment * variable was impossible - * + * */ static char* @@ -509,12 +509,12 @@ TclWeb_SelectEnvIncludeVar (rivet_thread_private* private,int idx) { switch (idx) { - case date_local: + case date_local: { apr_pool_t* pool = private->req->req->pool; apr_time_t date = private->req->req->request_time; - return ap_ht_time(pool,date,DEFAULT_TIME_FORMAT,0); + return ap_ht_time(pool,date,DEFAULT_TIME_FORMAT,0); } case date_gmt: { @@ -592,13 +592,13 @@ TclWeb_SelectEnvIncludeVar (rivet_thread_private* private,int idx) /* * -- TclWeb_InitEnvVars - * + * * Load the CGI and environment variables into the request_rec environment structure - * Variables belong to 3 cathegories + * Variables belong to 3 cathegories * * + common variables (ap_add_common_vars) * + CGI variables (ad_cgi_vars) - * + a miscellaneous set of variables + * + a miscellaneous set of variables * listed in the array include_env_vars * * Each cathegory is controlled by flags in order to reduce the overhead of getting them @@ -633,7 +633,7 @@ TclWeb_InitEnvVars (rivet_thread_private* private) if (!ENV_VARS_LOADED(req->environment_set)) { - apr_table_t *table; + apr_table_t *table; int idx; table = req->req->subprocess_env; @@ -656,7 +656,7 @@ TclWeb_InitEnvVars (rivet_thread_private* private) * a character string pointer to the environment variable value or * NULL if the environment variable name in invalid or the variable * could not be resolved - * + * */ static char* @@ -709,7 +709,7 @@ TclWeb_GetEnvVars(Tcl_Obj *envvar,rivet_thread_private* private) * Default behavior (creation in the ::request namespace) * is now more consistently constrained by fully qualifying * the default array names (see rivetCore.c). This should fix - * Bug #48963 + * Bug #48963 */ Tcl_ObjSetVar2(req->interp, envvar, key, val, 0); @@ -838,7 +838,7 @@ int TclWeb_UploadChannel(char *varname, TclWebRequest *req) result = Tcl_NewObj(); Tcl_SetStringObj(result, Tcl_GetChannelName(chan), -1); Tcl_SetObjResult(req->interp, result); - + return TCL_OK; } } @@ -889,7 +889,7 @@ int TclWeb_UploadData(char *varname, TclWebRequest *req) if (rsc->upload_files_to_var) { Tcl_Channel chan; - + chan = Tcl_OpenFileChannel (req->interp, req->upload->tempname, "r", 0); if (chan == NULL) { return TCL_ERROR; @@ -909,14 +909,14 @@ int TclWeb_UploadData(char *varname, TclWebRequest *req) if (Tcl_Close(req->interp, chan) == TCL_ERROR) { return TCL_ERROR; } - + Tcl_SetObjResult(req->interp, result); } else { Tcl_AppendResult(req->interp, "RivetServerConf UploadFilesToVar is not set", NULL); return TCL_ERROR; } - + return TCL_OK; } diff --git a/src/mod_rivet_ng/apache_config.c b/src/mod_rivet_ng/apache_config.c index dcd5d3f..1e0de26 100644 --- a/src/mod_rivet_ng/apache_config.c +++ b/src/mod_rivet_ng/apache_config.c @@ -1,6 +1,6 @@ /* apache_config.c -- configuration functions for apache 2.x */ -/* +/* Copyright 2002-2020 The Apache Tcl Team Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,17 +52,17 @@ extern mod_rivet_globals* module_globals; * - string_value: a string to be assigned to the Tcl_Obj * * Results: - * + * * - Pointer to a Tcl_Obj containing the parameter value. * */ #if 0 -static Tcl_Obj* +static Tcl_Obj* Rivet_AssignStringToConf (Tcl_Obj** objPnt, const char* string_value) { Tcl_Obj *objarg = NULL; - + if (*objPnt == NULL) { objarg = Tcl_NewStringObj(string_value,-1); @@ -81,7 +81,7 @@ static char* Rivet_AppendStringToConf (char* p,const char* string,apr_pool_t *pool) { - if (p == NULL) { + if (p == NULL) { p = apr_pstrdup(pool,string); } else { p = apr_pstrcat(pool,p,"\n",string,NULL); @@ -101,7 +101,7 @@ Rivet_AppendStringToConf (char* p,const char* string,apr_pool_t *pool) * * Results: * - * Returns a Tcl_Obj* pointing to the string representation of + * Returns a Tcl_Obj* pointing to the string representation of * the current value for the directive. * */ @@ -135,14 +135,14 @@ Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc, const char *script, c } else { return NULL; } - + *c = Rivet_AppendStringToConf(*c,string,pool); return *c; } -/* +/* * -- Rivet_GetConf * * Rivet_GetConf fetches the confguration from the server record @@ -155,8 +155,8 @@ Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc, const char *script, c * * Results: * - * - rivet_server_conf* rsc: the server merged configuration - * + * - rivet_server_conf* rsc: the server merged configuration + * * Side Effects: * * None. @@ -170,7 +170,7 @@ Rivet_GetConf( request_rec *r ) void *dconf = r->per_dir_config; rivet_server_conf *newconfig = NULL; rivet_server_conf *rdc; - + FILEDEBUGINFO; /* If there is no per dir config, just return the server config */ @@ -178,13 +178,13 @@ Rivet_GetConf( request_rec *r ) return rsc; } - /* things might become tedious when there are scripts set + /* things might become tedious when there are scripts set in a <Directory ...>...</Directory> stanza. Especially since we are calling this function at every single request. - We compute the new configuration merging the per-dir conf + We compute the new configuration merging the per-dir conf with the server configuration and then we return it. */ - rdc = RIVET_SERVER_CONF ( dconf ); + rdc = RIVET_SERVER_CONF ( dconf ); newconfig = RIVET_NEW_CONF ( r->pool ); Rivet_CopyConfig( rsc, newconfig ); @@ -242,12 +242,12 @@ Rivet_CopyConfig( rivet_server_conf *oldrsc, rivet_server_conf *newrsc ) /* * -- Rivet_MergeDirConfigVars - * + * * Merging of base configuration with per directory configuration * is done checking each field in the configuration record. If * a more specific (per directory) conf variable is defined then - * it supersedes the base record variable - * + * it supersedes the base record variable + * * Arguments: * * - apr_pool_t* t: pointer to an APR memory pool @@ -257,8 +257,8 @@ Rivet_CopyConfig( rivet_server_conf *oldrsc, rivet_server_conf *newrsc ) * - rivet_server_conf* add: * * Results: - * - * configuration record are merge in place + * + * configuration record are merge in place * * Side Effects: * @@ -304,11 +304,11 @@ Rivet_MergeDirConfigVars(apr_pool_t *p, rivet_server_conf *new, * -- Rivet_CreateDirConfig * * Apache HTTP server framework calls this function to - * have a pointer to newly initialized directory specific - * configuration record. + * have a pointer to newly initialized directory specific + * configuration record. * * Arguments: - * + * * - apr_pool_t*: pointer to an APR memory pool * - char*: string pointer to the directory name * @@ -340,11 +340,11 @@ Rivet_CreateDirConfig(apr_pool_t *p, char *dir) * Arguments: * * - apr_pool_t* p: pointer to an APR memory pool - * - void* basev, addv: pointers to configuration records to be + * - void* basev, addv: pointers to configuration records to be * merged - * + * * Results: - * + * * - void*: pointer to the resulting configuration */ @@ -416,7 +416,7 @@ Rivet_MergeConfig(apr_pool_t *p, void *basev, void *overridesv) //rsc->mpm_bridge = base->mpm_bridge; rsc->upload_max = base->upload_max; rsc->upload_dir = base->upload_dir; - + RIVET_CONF_SELECT(rsc,base,overrides,upload_dir) RIVET_CONF_SELECT(rsc,base,overrides,rivet_server_vars) @@ -468,7 +468,7 @@ Rivet_CreateConfig(apr_pool_t *p, server_rec *s ) //rsc->separate_virtual_interps = RIVET_SEPARATE_VIRTUAL_INTERPS; rsc->export_rivet_ns = RIVET_NAMESPACE_EXPORT; rsc->import_rivet_ns = RIVET_NAMESPACE_IMPORT; - rsc->honor_header_only_reqs = RIVET_HEAD_REQUESTS; + rsc->honor_head_requests = RIVET_HEAD_REQUESTS; //rsc->single_thread_exit = 0; //rsc->separate_channels = RIVET_SEPARATE_CHANNELS; rsc->upload_dir = RIVET_UPLOAD_DIR; @@ -495,9 +495,9 @@ Rivet_CreateConfig(apr_pool_t *p, server_rec *s ) */ const char * -Rivet_UserConf( cmd_parms *cmd, - void *vrdc, - const char *var, +Rivet_UserConf( cmd_parms *cmd, + void *vrdc, + const char *var, const char *val ) { rivet_server_conf *rdc = (rivet_server_conf *)vrdc; @@ -517,14 +517,14 @@ Rivet_UserConf( cmd_parms *cmd, rdc->user_scripts_status |= (USER_SCRIPTS_UPDATED | USER_SCRIPTS_CONF); - if (STREQU(var,"BeforeScript") || - STREQU(var,"AfterScript") || + if (STREQU(var,"BeforeScript") || + STREQU(var,"AfterScript") || STREQU(var,"AbortScript") || STREQU(var,"AfterEveryScript") || STREQU(var,"UploadDirectory") || STREQU(var,"ErrorScript")) { - apr_table_set( rdc->rivet_user_vars, var, + apr_table_set( rdc->rivet_user_vars, var, Rivet_SetScript( cmd->pool, rdc, var, val)); } else if (STREQU(var,"Debug") || @@ -536,7 +536,7 @@ Rivet_UserConf( cmd_parms *cmd, } else { - return apr_pstrcat(cmd->pool, "Rivet configuration error: '",var, + return apr_pstrcat(cmd->pool, "Rivet configuration error: '",var, "' not valid for RivetUserConf", NULL); } @@ -569,14 +569,14 @@ Rivet_DirConf(cmd_parms *cmd,void *vrdc,const char *var,const char *val) return "Rivet Error: RivetDirConf requires two arguments"; } - if(STREQU(var, "UploadDirectory")) + if(STREQU(var, "UploadDirectory")) { rdc->upload_dir = val; - } - else + } + else { - if (STREQU(var,"BeforeScript") || - STREQU(var,"AfterScript") || + if (STREQU(var,"BeforeScript") || + STREQU(var,"AfterScript") || STREQU(var,"AbortScript") || STREQU(var,"AfterEveryScript") || STREQU(var,"ErrorScript")) @@ -585,7 +585,7 @@ Rivet_DirConf(cmd_parms *cmd,void *vrdc,const char *var,const char *val) } else { - return apr_pstrcat(cmd->pool, "Rivet configuration error: '",var, + return apr_pstrcat(cmd->pool, "Rivet configuration error: '",var, "' not valid in <Directory> sections", NULL); } } diff --git a/src/mod_rivet_ng/mod_rivet.c b/src/mod_rivet_ng/mod_rivet.c index d7e3331..088d1f2 100644 --- a/src/mod_rivet_ng/mod_rivet.c +++ b/src/mod_rivet_ng/mod_rivet.c @@ -108,16 +108,16 @@ Rivet_SeekMPMBridge (apr_pool_t* pool) apr_status_t apr_ret; apr_finfo_t finfo; - /* With the env variable RIVET_MPM_BRIDGE we have the chance to tell mod_rivet + /* With the env variable RIVET_MPM_BRIDGE we have the chance to tell mod_rivet what bridge custom implementation we want be loaded */ if (apr_env_get (&mpm_bridge_path,"RIVET_MPM_BRIDGE",pool) == APR_SUCCESS) { if ((apr_ret = apr_stat(&finfo,mpm_bridge_path,APR_FINFO_MIN,pool)) != APR_SUCCESS) { - ap_log_perror(APLOG_MARK,APLOG_ERR,apr_ret,pool, - MODNAME ": MPM bridge %s not found", module_globals->mpm_bridge); - exit(1); + ap_log_perror(APLOG_MARK,APLOG_ERR,apr_ret,pool, + MODNAME ": MPM bridge %s not found", module_globals->mpm_bridge); + exit(1); } return mpm_bridge_path; } @@ -141,8 +141,8 @@ Rivet_SeekMPMBridge (apr_pool_t* pool) { ap_log_perror(APLOG_MARK,APLOG_ERR,apr_ret,pool, MODNAME ": MPM bridge %s (%s) not found",module_globals->mpm_bridge, - proposed_bridge); - exit(1); + proposed_bridge); + exit(1); } } else { @@ -180,25 +180,25 @@ Rivet_SeekMPMBridge (apr_pool_t* pool) return mpm_bridge_path; } -/* +/* * -- Rivet_CreateModuleGlobals * * module globals (mod_rivet_globals) allocation and initialization. * As of 3.2 the procedure fills the structure fields that can be set * during the pre_config stage of the server initialization - * + * */ -static mod_rivet_globals* +static mod_rivet_globals* Rivet_CreateModuleGlobals (apr_pool_t* pool) { mod_rivet_globals* mod_rivet_g; - + mod_rivet_g = apr_pcalloc(pool,sizeof(mod_rivet_globals)); mod_rivet_g->single_thread_exit = SINGLE_THREAD_EXIT_UNDEF; mod_rivet_g->separate_virtual_interps = RIVET_SEPARATE_VIRTUAL_INTERPS; mod_rivet_g->separate_channels = RIVET_SEPARATE_CHANNELS; - if (apr_pool_create(&mod_rivet_g->pool, NULL) != APR_SUCCESS) + if (apr_pool_create(&mod_rivet_g->pool, NULL) != APR_SUCCESS) { ap_log_perror(APLOG_MARK,APLOG_ERR,APR_EGENERAL,pool, MODNAME ": could not initialize rivet module global pool"); @@ -211,7 +211,7 @@ Rivet_CreateModuleGlobals (apr_pool_t* pool) &mod_rivet_g->default_handler, &mod_rivet_g->default_handler_size) > 0) { - ap_log_perror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, pool, + ap_log_perror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, pool, MODNAME ": could not read rivet default handler"); exit(1); } @@ -222,7 +222,7 @@ Rivet_CreateModuleGlobals (apr_pool_t* pool) /* * -- Rivet_Exit_Handler * - * + * * */ @@ -233,7 +233,7 @@ int Rivet_Exit_Handler(int code) return TCL_OK; /* Better not ever reach this! */ } -/* +/* * -- Rivet_RunServerInit * * Server initialization @@ -274,11 +274,11 @@ Rivet_RunServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, ser #ifdef WIN32 /* This code conditionally compiled when we are building for the - * Windows family of OS. The winnt MPM runs the post_config + * Windows family of OS. The winnt MPM runs the post_config * hooks after it has spawned a child process but we don't want * to run the Tcl server initialization script again. We * detect we are in a child process by checking - * the environment variable AP_PARENT_PID + * the environment variable AP_PARENT_PID * (https://wiki.apache.org/httpd/ModuleLife) */ @@ -327,7 +327,7 @@ Rivet_RunServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, ser * created an interpreter so far we create one */ - if ((interp_obj == NULL) || module_globals->separate_virtual_interps) + if ((interp_obj == NULL) || module_globals->separate_virtual_interps) { interp_obj = Rivet_NewVHostInterp(private,vhost_rsc->default_cache_size); @@ -447,10 +447,10 @@ Rivet_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server { char errorbuf[ERRORBUF_SZ]; - ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, - MODNAME ": Error loading symbol bridge_jump_table: %s", + ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + MODNAME ": Error loading symbol bridge_jump_table: %s", apr_dso_error(dso_handle,errorbuf,ERRORBUF_SZ)); - exit(1); + exit(1); } /* we require only request_processor and thread_interp to be defined */ @@ -467,8 +467,8 @@ Rivet_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server /* If we don't find the mpm handler module we give up and exit */ - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, - MODNAME " Error loading MPM manager: %s", + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + MODNAME " Error loading MPM manager: %s", apr_dso_error(dso_handle,errorbuf,ERRORBUF_SZ)); exit(1); } @@ -502,12 +502,12 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server) // ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pChild) == APR_SUCCESS); - /* This code is run once per child process. The forking + /* This code is run once per child process. The forking * of a child process doesn't preserve the thread where the Tcl - * notifier runs. The Notifier should have been restarted by one the + * notifier runs. The Notifier should have been restarted by one the * pthread_atfork callbacks (setup in Tcl >= 8.5.14 and Tcl >= 8.6.1). In * case pthread_atfork is not supported we unconditionally call Tcl_InitNotifier - * hoping for the best (Bug #55153) + * hoping for the best (Bug #55153) */ #if !defined(HAVE_PTHREAD_ATFORK) @@ -526,15 +526,15 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server) module_globals->server = server; } - /* This mutex should protect the process wide pool from concurrent access by + /* This mutex should protect the process wide pool from concurrent access by * different threads */ apr_thread_mutex_create(&module_globals->pool_mutex, APR_THREAD_MUTEX_UNNESTED, pChild); /* Once we have established a pool with the same lifetime of the child process we - * process all the configured server records assigning an integer as unique key - * to each of them + * process all the configured server records assigning an integer as unique key + * to each of them */ root_server_conf = RIVET_SERVER_CONF(server->module_config); @@ -568,9 +568,9 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server) } -static int Rivet_Handler(request_rec *r) +static int Rivet_Handler(request_rec *r) { - rivet_req_ctype ctype = Rivet_CheckType(r); + rivet_req_ctype ctype = Rivet_CheckType(r); if (ctype == CTYPE_NOT_HANDLED) { return DECLINED; } @@ -589,7 +589,7 @@ static int Rivet_InitGlobals (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *p /* * -- rivet_register_hooks: mod_rivet basic setup. * - * + * */ static void rivet_register_hooks(apr_pool_t *p) @@ -615,9 +615,9 @@ const command_rec rivet_cmds[] = /* Dispatch list for API hooks */ -module AP_MODULE_DECLARE_DATA rivet_module = +module AP_MODULE_DECLARE_DATA rivet_module = { - STANDARD20_MODULE_STUFF, + STANDARD20_MODULE_STUFF, Rivet_CreateDirConfig, /* create per-dir config structures */ Rivet_MergeDirConfig, /* merge per-dir config structures */ Rivet_CreateConfig, /* create per-server config structures */ diff --git a/src/mod_rivet_ng/mod_rivet.h b/src/mod_rivet_ng/mod_rivet.h index f90afb6..c107690 100644 --- a/src/mod_rivet_ng/mod_rivet.h +++ b/src/mod_rivet_ng/mod_rivet.h @@ -58,7 +58,7 @@ /* Configuration options */ -/* +/* If you do not have a threaded Tcl, you can define this to 0. This has the effect of running Tcl Init code in the main parent init handler, instead of in child init handlers. @@ -95,7 +95,7 @@ * Petasis 10 Aug 2017: This causes the symbol to be exported also from MPMs... module AP_MODULE_DECLARE_DATA rivet_module; - + */ typedef struct _rivet_server_conf { @@ -195,7 +195,7 @@ typedef struct _mpm_bridge_table { typedef struct mpm_bridge_status mpm_bridge_status; typedef struct _mod_rivet_globals { - apr_pool_t* pool; + apr_pool_t* pool; char* rivet_mpm_bridge; /* name of the MPM bridge */ server_rec* server; /* default host server_rec obj */ int ap_child_shutdown; /* shutdown inited by the child pool cleanup */ @@ -216,7 +216,7 @@ typedef struct _mod_rivet_globals { int single_thread_exit; /* With a threaded bridge allow a single */ /* thread to exit instead of forcing the */ /* whole process to terminate */ - int separate_virtual_interps; + int separate_virtual_interps; /* Virtual host have their own interpreter */ int separate_channels; /* when true a vhosts get their private channel */ #ifdef RIVET_SERIALIZE_HTTP_REQUESTS @@ -299,17 +299,17 @@ Tcl_Obj* Rivet_CurrentServerRec (Tcl_Interp* interp, server_rec* s); /* Configuration defaults */ -#define SINGLE_THREAD_EXIT_UNDEF -1 /* pre config undefined value for single +#define SINGLE_THREAD_EXIT_UNDEF -1 /* pre config undefined value for single thread exit flag in the module globals structure */ #define TCL_MAX_CHANNEL_BUFFER_SIZE (1024*1024) #define MODNAME "mod_rivet" -/* - * RIVET_CONF_SELECT: +/* + * RIVET_CONF_SELECT: * - * This macro avoids unnecessary verbosity of repetitive code in functions + * This macro avoids unnecessary verbosity of repetitive code in functions * overlaying and merging configuration records */ diff --git a/src/mod_rivet_ng/mod_rivet_cache.c b/src/mod_rivet_ng/mod_rivet_cache.c index 151c8ce..15fe958 100644 --- a/src/mod_rivet_ng/mod_rivet_cache.c +++ b/src/mod_rivet_ng/mod_rivet_cache.c @@ -51,12 +51,12 @@ int RivetCache_DefaultSize (void) } /* - * -- RivetCache_Create + * -- RivetCache_Create * * Creates a per interpreter script cach * * Arguments: - * apr_pool_t *p - APR memory pool pointer, + * apr_pool_t *p - APR memory pool pointer, * rivet_thread_interp* interp_obj - interpreter object * * @@ -144,25 +144,25 @@ void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rive ct++; } apr_pool_destroy(rivet_interp->pool); - + /* let's recreate the cache list */ if (apr_pool_create(&rivet_interp->pool, private->pool) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, MODNAME ": could not recreate cache private pool. Cache disabled"); rivet_interp->cache_free = rivet_interp->cache_size = 0; } else { - rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool, + rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool, (signed)(rivet_interp->cache_size*sizeof(char *))); rivet_interp->cache_free = rivet_interp->cache_size; } - + } -/* +/* * -- Rivet_MakeCacheKey * * Arguments: @@ -176,7 +176,7 @@ void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rive char* RivetCache_MakeKey (apr_pool_t* pool, char* filename, - time_t ctime, + time_t ctime, time_t mtime, unsigned int user_conf, int toplevel) @@ -253,7 +253,7 @@ Tcl_Obj* RivetCache_FetchScript (Tcl_HashEntry* entry) return (Tcl_Obj *)Tcl_GetHashValue(entry); } -/* -- RivetCache_StoreScript +/* -- RivetCache_StoreScript * */ @@ -265,14 +265,14 @@ int RivetCache_StoreScript(rivet_thread_interp* rivet_interp, Tcl_HashEntry* ent char* hashKey = (char *) Tcl_GetHashKey (rivet_interp->objCache,entry); /* Tcl_SetHashValue is a macro that simply stuffs the value pointer in an array - * We need to incr the reference count of outbuf because we want it to outlive + * We need to incr the reference count of outbuf because we want it to outlive * this function and be kept as long as the cache is preserved */ Tcl_IncrRefCount (script); Tcl_SetHashValue (entry,(ClientData)script); - rivet_interp->objCacheList[--rivet_interp->cache_free] = + rivet_interp->objCacheList[--rivet_interp->cache_free] = (char*) apr_pcalloc (rivet_interp->pool,(strlen(hashKey)+1)*sizeof(char)); strcpy(rivet_interp->objCacheList[rivet_interp->cache_free], hashKey); diff --git a/src/mod_rivet_ng/mod_rivet_cache.h b/src/mod_rivet_ng/mod_rivet_cache.h index 8f86f6e..c1cb4c5 100644 --- a/src/mod_rivet_ng/mod_rivet_cache.h +++ b/src/mod_rivet_ng/mod_rivet_cache.h @@ -25,7 +25,7 @@ EXTERN int RivetCache_DefaultSize (void); EXTERN void RivetCache_Create (rivet_thread_interp* interp_obj); EXTERN void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rivet_interp); EXTERN char* RivetCache_MakeKey (apr_pool_t* pool, char* filename, - time_t ctime, + time_t ctime, time_t mtime, unsigned int user_conf, int toplevel); diff --git a/src/mod_rivet_ng/mod_rivet_common.c b/src/mod_rivet_ng/mod_rivet_common.c index a829ae1..35fe13b 100644 --- a/src/mod_rivet_ng/mod_rivet_common.c +++ b/src/mod_rivet_ng/mod_rivet_common.c @@ -1,5 +1,5 @@ -/* -- mod_rivet_common.c - functions likely to be shared among different - * components of mod_rivet.c +/* -- mod_rivet_common.c - functions likely to be shared among different + * components of mod_rivet.c */ /* @@ -63,7 +63,7 @@ extern module rivet_module; * */ -rivet_thread_interp* +rivet_thread_interp* Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj) { rivet_thread_interp* interp_obj = apr_pcalloc(pool,sizeof(rivet_thread_interp)); @@ -77,19 +77,19 @@ Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj) /* An intepreter must have its own cache */ if (interp_obj->cache_size) { - RivetCache_Create(interp_obj); + RivetCache_Create(interp_obj); } interp_obj->pool = source_obj->pool; interp_obj->scripts = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts)); - interp_obj->per_dir_scripts = apr_hash_make(pool); + interp_obj->per_dir_scripts = apr_hash_make(pool); interp_obj->flags = source_obj->flags; return interp_obj; } /* * -- Rivet_ReadFile - * + * */ int @@ -106,7 +106,7 @@ Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes) { return 1; } - + if (apr_file_open(&apr_fp,filename,APR_FOPEN_READ, APR_FPROT_OS_DEFAULT, pool) != APR_SUCCESS) @@ -116,14 +116,14 @@ Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes) buffer_size = file_info->size; *buffer = (char*) apr_palloc(pool,buffer_size); - + if (apr_file_read(apr_fp,*buffer,&buffer_size) != APR_SUCCESS) { return 2; } apr_file_close(apr_fp); - + *nbytes = (int)buffer_size; return 0; } @@ -136,13 +136,13 @@ Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes) * * Results: * pointer to a Tcl_Interp structure - * + * * Side Effects: * *----------------------------------------------------------------------------- */ -static Tcl_Interp* +static Tcl_Interp* Rivet_CreateTclInterp (apr_pool_t* pool) { Tcl_Interp* interp; @@ -195,21 +195,21 @@ running_scripts* Rivet_RunningScripts ( apr_pool_t* pool, ap_assert(Rivet_ReadFile(pool,rivet_conf->request_handler, &request_handler,&handler_size) == 0); - scripts->request_processing = + scripts->request_processing = Tcl_NewStringObj(request_handler,handler_size); } else { - scripts->request_processing = + scripts->request_processing = Tcl_NewStringObj(module_globals->default_handler, module_globals->default_handler_size); - } + } Tcl_IncrRefCount(scripts->request_processing); return scripts; } /* - * -- Rivet_ReleaseRunningScripts + * -- Rivet_ReleaseRunningScripts * */ @@ -261,7 +261,7 @@ void Rivet_ReleasePerDirScripts(rivet_thread_interp* rivet_interp) *--------------------------------------------------------------------- */ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj, - rivet_thread_private* private, + rivet_thread_private* private, server_rec *server, apr_pool_t *p) { @@ -281,15 +281,15 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj, //globals = ckalloc(sizeof(rivet_interp_globals)); //Tcl_SetAssocData (interp,"rivet",NULL,globals); - + /* * the ::rivet namespace is the only information still stored - * in the interpreter global data + * in the interpreter global data */ /* Rivet commands namespace is created */ - interp_obj->rivet_ns = + interp_obj->rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,private,(Tcl_NamespaceDeleteProc *)NULL); /* We put in front the auto_path list the path to the directory where @@ -307,7 +307,7 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj, if (Tcl_ListObjReplace(interp,auto_path,0,0,1,&rivet_tcl) == TCL_ERROR) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": error setting auto_path: %s", Tcl_GetStringFromObj(auto_path,NULL)); } else { @@ -318,9 +318,9 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj, /* If the thread has private data we stuff the server conf * pointer in the 'running_conf' field. - * Commands running ouside a request processing must figure out - * themselves how get a pointer to the configuration from the - * context (e.g. ::rivet::inspect) + * Commands running ouside a request processing must figure out + * themselves how get a pointer to the configuration from the + * context (e.g. ::rivet::inspect) */ if (private != NULL) private->running_conf = RIVET_SERVER_CONF (server->module_config); @@ -356,10 +356,10 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj, /* -- Rivet_NewVHostInterp * * Returns a new rivet_thread_interp object with a new Tcl interpreter - * configuration scripts and cache. The pool passed to Rivet_NewVHostInterp + * configuration scripts and cache. The pool passed to Rivet_NewVHostInterp * - * Arguments: - * apr_pool_t* pool: a memory pool, it must be the private pool of a + * Arguments: + * apr_pool_t* pool: a memory pool, it must be the private pool of a * rivet_thread_private object (thread private) * * Returned value: @@ -374,14 +374,14 @@ rivet_thread_interp* Rivet_NewVHostInterp (rivet_thread_private* private,int def /* This calls needs the root server_rec just for logging purposes */ - interp_obj->interp = Rivet_CreateTclInterp(private->pool); + interp_obj->interp = Rivet_CreateTclInterp(private->pool); /* we now create memory from the cache pool as subpool of the thread private pool */ - + apr_sts = apr_pool_create(&interp_obj->pool, private->pool); if (apr_sts != APR_SUCCESS) { - ap_log_perror(APLOG_MARK, APLOG_ERR, apr_sts, private->pool, + ap_log_perror(APLOG_MARK, APLOG_ERR, apr_sts, private->pool, MODNAME ": could not initialize cache private pool"); return NULL; } @@ -397,12 +397,12 @@ rivet_thread_interp* Rivet_NewVHostInterp (rivet_thread_private* private,int def // Initialize cache structures if (interp_obj->cache_size) { - RivetCache_Create(interp_obj); + RivetCache_Create(interp_obj); } interp_obj->flags = 0; interp_obj->scripts = (running_scripts *) apr_pcalloc(private->pool,sizeof(running_scripts)); - interp_obj->per_dir_scripts = apr_hash_make(private->pool); + interp_obj->per_dir_scripts = apr_hash_make(private->pool); return interp_obj; } @@ -442,7 +442,7 @@ Rivet_CreateRivetChannel(apr_pool_t* pPool, apr_threadkey_t* rivet_thread_key) Tcl_SetStdChannel (*(outchannel), TCL_STDOUT); - /* Set the output buffer size to the largest allowed value, so that we + /* Set the output buffer size to the largest allowed value, so that we * won't send any result packets to the browser unless the Rivet * programmer does a "flush stdout" or the page is completed. */ @@ -470,34 +470,34 @@ Rivet_CreateRivetChannel(apr_pool_t* pPool, apr_threadkey_t* rivet_thread_key) * * Side Effects: * - * channel debug counter decremented (TODO) + * channel debug counter decremented (TODO) * *----------------------------------------------------------------------------- */ -void +void Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel) { - Tcl_UnregisterChannel(interp,*channel); + Tcl_UnregisterChannel(interp,*channel); } /*----------------------------------------------------------------------------- * - * -- Rivet_CreatePrivateData + * -- Rivet_CreatePrivateData * * Creates a thread private data object * * Arguments: - * + * * - apr_pool_t* pPool: parent thread memory pool * - bool create_req_obj: the field req (ApacheTcl_Req *) has to be allocated. * Thread private data structures created during server * initialization don't need to process any HTTP request - * Prefork based bridges need to allocate it themselves + * Prefork based bridges need to allocate it themselves * * Returned value: - * + * * - rivet_thread_private* thread private data structure instance * *----------------------------------------------------------------------------- @@ -516,9 +516,9 @@ rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* tPool,bool create_req /* if (create_pool) { - if (apr_pool_create (&private->pool, NULL) != APR_SUCCESS) + if (apr_pool_create (&private->pool, NULL) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, MODNAME ": could not create thread private pool"); return NULL; } @@ -557,12 +557,12 @@ rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* tPool,bool create_req * * Returned value: * - * - initialized rivet_thread_private* data record - * + * - initialized rivet_thread_private* data record + * *----------------------------------------------------------------------------- */ -rivet_thread_private* +rivet_thread_private* Rivet_SetupTclPanicProc (void) { rivet_thread_private* private; @@ -606,13 +606,13 @@ void Rivet_Panic TCL_VARARGS_DEF(CONST char *, arg1) buf = (char *) apr_pvsprintf(private->rivet_panic_pool, format, argList); if (private->rivet_panic_request_rec != NULL) { - ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL, + ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL, private->rivet_panic_server_rec, - MODNAME ": Critical error in request: %s", + MODNAME ": Critical error in request: %s", private->rivet_panic_request_rec->unparsed_uri); } - ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL, + ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL, private->rivet_panic_server_rec, "%s", buf); abort(); @@ -623,9 +623,9 @@ void Rivet_Panic TCL_VARARGS_DEF(CONST char *, arg1) * * This function is meant to release memory and resorces * owned by a thread. - * The handler in general is not guaranteed to be called - * within the same thread that created the resources to - + release. As such it's useless to release any Tcl + * The handler in general is not guaranteed to be called + * within the same thread that created the resources to + + release. As such it's useless to release any Tcl * related resorces (e.g. a Tcl_Interp* object) as * any threaded build of Tcl uses its own thread private * data. We leave the function as a placeholder @@ -672,8 +672,8 @@ void Rivet_CleanupRequest( request_rec *r ) * RIVET_INIT - Rivet's init.tcl file * RIVET_VERSION - Rivet version (only when RIVET_DISPLAY_VERSION is 1) * MPM_THREADED - It should contain the string 'unsupported' for a prefork MPM - * MPM_FORKED - String describing the forking model of the MPM - * RIVET_MPM_BRIDGE - Filename of the running MPM bridge + * MPM_FORKED - String describing the forking model of the MPM + * RIVET_MPM_BRIDGE - Filename of the running MPM bridge * */ @@ -731,7 +731,7 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) if (ap_mpm_query(AP_MPMQ_IS_THREADED,&ap_mpm_result) == APR_SUCCESS) { - switch (ap_mpm_result) + switch (ap_mpm_result) { case AP_MPMQ_STATIC: obj = Tcl_NewStringObj("static", -1); @@ -739,7 +739,7 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) case AP_MPMQ_NOT_SUPPORTED: obj = Tcl_NewStringObj("unsupported", -1); break; - default: + default: obj = Tcl_NewStringObj("undefined", -1); break; } @@ -750,7 +750,7 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) if (ap_mpm_query(AP_MPMQ_IS_FORKED,&ap_mpm_result) == APR_SUCCESS) { - switch (ap_mpm_result) + switch (ap_mpm_result) { case AP_MPMQ_STATIC: obj = Tcl_NewStringObj("static", -1); @@ -758,7 +758,7 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) case AP_MPMQ_DYNAMIC: obj = Tcl_NewStringObj("dynamic", -1); break; - default: + default: obj = Tcl_NewStringObj("undefined", -1); break; } @@ -775,7 +775,7 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) obj, TCL_GLOBAL_ONLY); Tcl_DecrRefCount(obj); - + obj = Tcl_NewStringObj(RIVET_CONFIGURE_CMD,-1); Tcl_IncrRefCount(obj); Tcl_SetVar2Ex(interp, @@ -789,21 +789,21 @@ void Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *pool ) /* * -- Rivet_chdir_file (const char* filename) - * + * * Determines the directory name from the filename argument * and sets it as current working directory * * Argument: - * + * * const char* filename: file name to be used for determining * the current directory (URI style path) * the directory name is everything comes * before the last '/' (slash) character * - * This snippet of code came from the mod_ruby project, + * This snippet of code came from the mod_ruby project, * which is under a BSD license. */ - + int Rivet_chdir_file (const char *file) { const char *x; @@ -836,7 +836,7 @@ int Rivet_chdir_file (const char *file) * * Executes a Tcl code fragment to import into the global space * the commands created in the ::rivet namespace - * + * * Arguments: * * - server_rec* server @@ -857,9 +857,9 @@ void Rivet_ImportNamespace (server_rec* server,rivet_thread_interp* interp) { rivet_server_conf* rsc; server_rec* s; - char* tcl_import_cmd = + char* tcl_import_cmd = "namespace eval :: { namespace import -force ::rivet::* }\n"; - + for (s = server; s != NULL; s = s->next) { int idx; @@ -875,9 +875,9 @@ void Rivet_ImportNamespace (server_rec* server,rivet_thread_interp* interp) /* -- Rivet_EvalScript * - * Utility function to evaluate single Tcl scripts like configuration - * specified script (GlobalInitScript,ChildInitScript and ChildExitScript) - * + * Utility function to evaluate single Tcl scripts like configuration + * specified script (GlobalInitScript,ChildInitScript and ChildExitScript) + * * */ @@ -892,19 +892,19 @@ int Rivet_EvalScript (server_rec* server, if (tcl_retcode != TCL_OK) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME "errorCode: %s", Tcl_GetVar(interp_obj->interp, "errorCode", 0)); - ap_log_error(APLOG_MARK,APLOG_ERR,APR_EGENERAL,server, + ap_log_error(APLOG_MARK,APLOG_ERR,APR_EGENERAL,server, MODNAME ": Error running '%s': %s",script_name, Tcl_GetVar(interp_obj->interp,"errorInfo",0)); } else { - ap_log_error(APLOG_MARK,APLOG_DEBUG,0,server, + ap_log_error(APLOG_MARK,APLOG_DEBUG,0,server, MODNAME ": GlobalInitScript '%s' successful",script_name); } - + return tcl_retcode; } diff --git a/src/mod_rivet_ng/mod_rivet_common.h b/src/mod_rivet_ng/mod_rivet_common.h index 057d20a..7792411 100644 --- a/src/mod_rivet_ng/mod_rivet_common.h +++ b/src/mod_rivet_ng/mod_rivet_common.h @@ -1,4 +1,4 @@ -/* -- mod_rivet_common.h Declariations for common utility functions */ +/* -- mod_rivet_common.h Declariations for common utility functions */ /* Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/mod_rivet_ng/mod_rivet_generator.c b/src/mod_rivet_ng/mod_rivet_generator.c index 2299fb3..7d81d7f 100644 --- a/src/mod_rivet_ng/mod_rivet_generator.c +++ b/src/mod_rivet_ng/mod_rivet_generator.c @@ -43,7 +43,7 @@ extern apr_threadkey_t* rivet_thread_key; extern module rivet_module; -/* +/* * -- Rivet_CheckType (request_rec *r) * * Utility function internally used to determine which type @@ -52,7 +52,7 @@ extern module rivet_module; * the test returns an integer (RIVET_TEMPLATE) for rvt templates * or RIVET_TCLFILE for Tcl scripts * - * Argument: + * Argument: * * request_rec*: pointer to the current request record * @@ -78,14 +78,14 @@ Rivet_CheckType (request_rec *req) ctype = RIVET_TCLFILE; } } - return ctype; + return ctype; } /* * -- Rivet_ReleaseScript * * - * + * * * */ @@ -130,8 +130,8 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) /* Set the global request req to know what we are dealing with in * case we have to call the PanicProc. */ - /* TODO: we can't place a pointer to the request rec here, if Tcl_Panic - gets called in general it won't have this pointer which has to be + /* TODO: we can't place a pointer to the request rec here, if Tcl_Panic + gets called in general it won't have this pointer which has to be thread private */ private->rivet_panic_request_rec = private->r; @@ -150,19 +150,19 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) { rivet_server_conf* rdc = NULL; - rdc = RIVET_SERVER_CONF(private->r->per_dir_config); + rdc = RIVET_SERVER_CONF(private->r->per_dir_config); if ((rdc != NULL) && (rdc->path)) { /* Let's check if a scripts object is already stored in the per-dir hash table */ - private->running = + private->running = (running_scripts *) apr_hash_get (interp_obj->per_dir_scripts,rdc->path,strlen(rdc->path)); if (private->running == NULL) { rivet_server_conf* newconfig = NULL; - running_scripts* scripts = + running_scripts* scripts = (running_scripts *) apr_pcalloc (private->pool,sizeof(running_scripts)); newconfig = RIVET_NEW_CONF(private->r->pool); @@ -214,9 +214,9 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) private->r->allowed |= (1 << M_POST); private->r->allowed |= (1 << M_PUT); private->r->allowed |= (1 << M_DELETE); - if (private->r->method_number != M_GET && - private->r->method_number != M_POST && - private->r->method_number != M_PUT && + if (private->r->method_number != M_GET && + private->r->method_number != M_POST && + private->r->method_number != M_PUT && private->r->method_number != M_DELETE) { retval = DECLINED; @@ -228,7 +228,7 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) { request_rec* r = private->r; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, private->r->server, MODNAME ": File does not exist: %s", (r->path_info ? (char*)apr_pstrcat(r->pool, r->filename, r->path_info, NULL) : r->filename)); @@ -241,7 +241,7 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) goto sendcleanup; } - /* + /* * This one is the big catch when it comes to moving towards * Apache 2.0, or one of them, at least. */ @@ -253,8 +253,8 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) /* something went wrong doing chdir into r->filename, we are not specific * at this. We simply emit an internal server error and print a log message */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server, - MODNAME ": Error accessing %s, could not chdir into directory", + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server, + MODNAME ": Error accessing %s, could not chdir into directory", r->filename); retval = HTTP_INTERNAL_SERVER_ERROR; @@ -304,23 +304,23 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r) doing caching on the modification time of the .htaccess files that concern us. FIXME */ - if (USER_CONF_UPDATED(private->running_conf) && (interp_obj->cache_size != 0) && - (interp_obj->cache_free < interp_obj->cache_size)) + if (USER_CONF_UPDATED(private->running_conf) && (interp_obj->cache_size != 0) && + (interp_obj->cache_free < interp_obj->cache_size)) { RivetCache_Cleanup(private,interp_obj); } /* URL referenced script execution and exception handling */ - if (Tcl_EvalObjEx(interp, private->running->request_processing,0) == TCL_ERROR) + if (Tcl_EvalObjEx(interp, private->running->request_processing,0) == TCL_ERROR) { /* we don't report errors coming from abort_page execution */ - if (!private->page_aborting) + if (!private->page_aborting) { request_rec* r = private->r; - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, MODNAME ": Error evaluating exec file '%s': %s", r->filename, Tcl_GetVar(interp, "errorInfo", 0)); } @@ -353,10 +353,10 @@ sendcleanup: * has been evaluated the exit condition is checked and the bridge * exit handler is called upon. */ - + if (private->thread_exit) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, private->r, + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, private->r, "thread terminating with code %d",private->exit_status); RIVET_MPM_BRIDGE_CALL(exit_handler,private); //Tcl_Exit(private->exit_status); diff --git a/src/mod_rivet_ng/rivetChannel.c b/src/mod_rivet_ng/rivetChannel.c index d6ec90f..8b55236 100644 --- a/src/mod_rivet_ng/rivetChannel.c +++ b/src/mod_rivet_ng/rivetChannel.c @@ -53,7 +53,7 @@ outputproc(ClientData instancedata, CONST84 char *buf, int toWrite, int *errorCo { apr_threadkey_t* rivet_thread_key = (apr_threadkey_t*) instancedata; rivet_thread_private* private; - + apr_threadkey_private_get ((void **)&private,rivet_thread_key); TclWeb_PrintHeaders(private->req); diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c index 67df546..5df441f 100644 --- a/src/mod_rivet_ng/rivetCore.c +++ b/src/mod_rivet_ng/rivetCore.c @@ -77,7 +77,7 @@ extern apr_threadkey_t* rivet_thread_key; /* * -- Rivet_NoRequestRec * - * Adds standard error information to the interpreter. This procedure makes + * Adds standard error information to the interpreter. This procedure makes * sense only when called by C functions implementing Tcl commands that * are meaningful only if a valid requiest_rec object is defined. These * procedures must return TCL_ERROR right away after Rivet_NoRequestRecord @@ -158,9 +158,9 @@ TCL_CMD_HEADER( Rivet_MakeURL ) if (script_name_l > 0) { - // script name may have the form a directory path (and mod_rewrite + // script name may have the form a directory path (and mod_rewrite // could have mapped it to a .tcl or .rvt script) - + if (script_name[script_name_l-1] == '/') { url_target_name = apr_pstrcat(private->req->req->pool,script_name,url_target_name,NULL); @@ -177,7 +177,7 @@ TCL_CMD_HEADER( Rivet_MakeURL ) } } - result = Tcl_NewObj(); + result = Tcl_NewObj(); TclWeb_MakeURL(result, url_target_name, private->req); Tcl_SetObjResult(interp, result); @@ -248,7 +248,7 @@ TCL_CMD_HEADER( Rivet_Parse ) if (Rivet_Parser(outbuf, script) == 0) { Tcl_AppendToObj(outbuf, "\"\n", 2); - } + } Tcl_AppendToObj(outbuf,"\n",-1); @@ -258,7 +258,7 @@ TCL_CMD_HEADER( Rivet_Parse ) return res; //return Rivet_ParseExecString(private, objv[2]); - } else { + } else { Tcl_WrongNumArgs( interp, 1, objv, "?-virtual? filename | -string template_string" ); return TCL_ERROR; @@ -284,7 +284,7 @@ TCL_CMD_HEADER( Rivet_Parse ) /* */ - cache_key = + cache_key = RivetCache_MakeKey( private->pool,filename, finfo_b.ctime,finfo_b.mtime, IS_USER_CONF(private->running_conf),0); @@ -326,10 +326,10 @@ TCL_CMD_HEADER( Rivet_Parse ) result = Tcl_EvalObjEx(interp,script,0); Tcl_DecrRefCount(script); return result; - + } else { script = RivetCache_FetchScript(entry); - return Tcl_EvalObjEx(interp,script,0); + return Tcl_EvalObjEx(interp,script,0); } } @@ -487,7 +487,7 @@ TCL_CMD_HEADER( Rivet_Headers ) return TCL_ERROR; } - header_value = TclWeb_OutputHeaderGet(Tcl_GetString(objv[2]),private->req); + header_value = TclWeb_OutputHeaderGet(Tcl_GetString(objv[2]),private->req); Tcl_SetObjResult(interp,Tcl_NewStringObj(header_value ? header_value : "",-1)); } @@ -656,7 +656,7 @@ TCL_CMD_HEADER ( Rivet_LoadHeaders ) TCL_CMD_HEADER ( Rivet_Var ) { rivet_thread_private* private; - const char* cmd; + const char* cmd; char* command; Tcl_Obj* result = NULL; int source; @@ -678,7 +678,7 @@ TCL_CMD_HEADER ( Rivet_Var ) /* determine if var_qs, var_post or var was called */ /* first of all we have to skip the namespace string at the beginning of the command: - * + * * This fragment of code is taken from tcl 8.6.6 (tclNamesp.c) and it's part of the * function implementing Tcl "namespace tail", as such it should be authoritative * regarding the stripping of the namespace from a FQ command name @@ -687,7 +687,7 @@ TCL_CMD_HEADER ( Rivet_Var ) for (p = cmd; *p != '\0'; p++) { /* empty body */ } - + while (--p > cmd) { if ((*p == ':') && (*(p-1) == ':')) { p++; /* Just after the last "::" */ @@ -808,9 +808,9 @@ TCL_CMD_HEADER ( Rivet_Var ) return TCL_ERROR; } - for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) + for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) { - if (Tcl_DictObjGet(interp,result,key,&valuePtr) == TCL_OK) + if (Tcl_DictObjGet(interp,result,key,&valuePtr) == TCL_OK) { if (valuePtr == NULL) { @@ -1210,7 +1210,7 @@ TCL_CMD_HEADER( Rivet_Upload ) Tcl_SetIntObj(result,upload_prepared); Tcl_SetObjResult(interp, result); return TCL_OK; - + } if (tcl_status != TCL_OK) @@ -1361,7 +1361,7 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) if (objc == 2) { char* cmd_arg = Tcl_GetStringFromObj(objv[1],NULL); - + if (strcmp(cmd_arg,"-aborting") == 0) { Tcl_SetObjResult (interp,Tcl_NewBooleanObj(private->page_aborting)); @@ -1373,12 +1373,12 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) Tcl_SetObjResult (interp,Tcl_NewBooleanObj(private->thread_exit)); return TCL_OK; } - - /* + + /* * we assume abort_code to be null, as abort_page shouldn't run twice while - * processing the same request + * processing the same request */ - + if (private->abort_code == NULL) { private->abort_code = objv[1]; @@ -1386,7 +1386,7 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) } } - /* + /* * If page_aborting is true then this is the second call to abort_page * processing the same request: we ignore it and return a normal * completion code @@ -1399,7 +1399,7 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) /* this is the first (and supposedly unique) abort_page call during this request */ - /* we eleveta the page_aborting flag to the actual flag controlling the page abort execution. + /* we eleveta the page_aborting flag to the actual flag controlling the page abort execution. * We still return the RIVET and ABORTPAGE_CODE, but internally * its page_aborting that will drive the code execution after abort_page */ @@ -1413,9 +1413,9 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) /* *----------------------------------------------------------------------------- - * Rivet_AbortCodeCmd -- + * Rivet_AbortCodeCmd -- * - * Returns the abort code stored internally by passing a user defined parameter + * Returns the abort code stored internally by passing a user defined parameter * to the command 'abort_page'. * * @@ -1424,7 +1424,7 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd ) TCL_CMD_HEADER( Rivet_AbortCodeCmd ) { rivet_thread_private* private; - + THREAD_PRIVATE_DATA(private) if (private->abort_code != NULL) @@ -1457,7 +1457,7 @@ TCL_CMD_HEADER( Rivet_EnvCmd ) char* key; char* val; rivet_thread_private* private; - + THREAD_PRIVATE_DATA(private) CHECK_REQUEST_REC(private,"::rivet::env") @@ -1483,14 +1483,14 @@ TCL_CMD_HEADER( Rivet_EnvCmd ) * as 'worker') the procedure should cause a thread to exit, not the * whole process with all its threads. In this case the procedure * returns an TCL_ERROR code that has to be handled in mod_rivet so that - * the error is ignored and the request procedure interrupted. - * For a non threaded MPM (such as 'prefork') the single child process - * exits thus reproducing an ordinary 'exit' command. + * the error is ignored and the request procedure interrupted. + * For a non threaded MPM (such as 'prefork') the single child process + * exits thus reproducing an ordinary 'exit' command. * * Result: * - * TCL_ERROR - * + * TCL_ERROR + * * Side Effects: * * - non threaded MPMs: the child process exits for good @@ -1522,14 +1522,14 @@ TCL_CMD_HEADER( Rivet_ExitCmd ) private->page_aborting = 1; private->abort_code = Tcl_NewDictObj(); - /* The private->abort_code ref count is decremented before + /* The private->abort_code ref count is decremented before * request processing terminates*/ Tcl_IncrRefCount(private->abort_code); /* - * mod_rivet traps every call to ::rivet::exit to offers a chance - * to the Tcl application interrupt execution much in + * mod_rivet traps every call to ::rivet::exit to offers a chance + * to the Tcl application interrupt execution much in * the same way it can be done by calling ::rivet::abort_page */ @@ -1594,7 +1594,7 @@ TCL_CMD_HEADER( Rivet_VirtualFilenameCmd ) * * Rivet_Inspect -- * - * Rivet configuration introspection. Command '::rivet::inspect' + * Rivet configuration introspection. Command '::rivet::inspect' * returns a dictionary of configuration data: * * Results: @@ -1606,7 +1606,7 @@ TCL_CMD_HEADER( Rivet_VirtualFilenameCmd ) TCL_CMD_HEADER( Rivet_InspectCmd ) { rivet_thread_private* private; - rivet_server_conf* rsc; + rivet_server_conf* rsc; int status = TCL_OK; THREAD_PRIVATE_DATA(private) @@ -1616,7 +1616,7 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) Tcl_Obj* dictObj; CHECK_REQUEST_REC(private,"::rivet::inspect") - rsc = Rivet_GetConf(private->r); + rsc = Rivet_GetConf(private->r); dictObj = Rivet_BuildConfDictionary(interp,rsc); if (dictObj != NULL) { Tcl_IncrRefCount(dictObj); @@ -1650,20 +1650,20 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) cmd = Tcl_NewStringObj("info script",-1); - Tcl_IncrRefCount(cmd); + Tcl_IncrRefCount(cmd); status = Tcl_EvalObjEx(interp,cmd,TCL_EVAL_DIRECT); Tcl_DecrRefCount(cmd); - } + } else if (STRNEQU(cmd_arg,"-all")) { Tcl_Obj* dictObj; - + CHECK_REQUEST_REC(private,"::rivet::inspect -all") - rsc = Rivet_GetConf(private->r); + rsc = Rivet_GetConf(private->r); dictObj = Rivet_CurrentConfDict(interp,rsc); Tcl_IncrRefCount(dictObj); - Tcl_SetObjResult(interp,dictObj); + Tcl_SetObjResult(interp,dictObj); Tcl_DecrRefCount(dictObj); } @@ -1677,7 +1677,7 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) } else { if (private->r == NULL) { - srec = module_globals->server; + srec = module_globals->server; } else { srec = private->r->server; } @@ -1688,14 +1688,14 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) dictObj = Rivet_CurrentServerRec(interp,srec); Tcl_IncrRefCount(dictObj); - Tcl_SetObjResult(interp,dictObj); + Tcl_SetObjResult(interp,dictObj); Tcl_DecrRefCount(dictObj); } else if (STRNEQU(cmd_arg,"exit")) { Tcl_Obj* exit_flag; - + CHECK_REQUEST_REC(private,"::rivet::inspect") /* thread exit status flag */ exit_flag = Tcl_NewIntObj(private->thread_exit); @@ -1716,7 +1716,7 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) if (private->r == NULL) { rsc = private->running_conf; } else { - rsc = Rivet_GetConf(private->r); + rsc = Rivet_GetConf(private->r); } } @@ -1743,7 +1743,7 @@ TCL_CMD_HEADER( Rivet_InspectCmd ) Tcl_DecrRefCount(par_name); } - else + else { Tcl_WrongNumArgs( interp, 1, objv, "?server | dir | user? ?parameter name?" ); status = TCL_ERROR; @@ -1851,7 +1851,7 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd ) break; } - /* if we are serving a page, we know our server, + /* if we are serving a page, we know our server, * else send null for server */ serverRec = ((private == NULL) || (private->r == NULL)) ? module_globals->server : private->r->server; @@ -1870,7 +1870,7 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd ) * Calls the panic routine. * * Results: - * Always returns TCL_OK. + * Always returns TCL_OK. * * Side effects: * May exit application. @@ -1926,7 +1926,7 @@ TCL_CMD_HEADER( Rivet_UrlScript ) Tcl_HashEntry* entry = NULL; Tcl_Obj* script = NULL; int result; - unsigned int user_conf; + unsigned int user_conf; time_t ctime; time_t mtime; @@ -1944,7 +1944,7 @@ TCL_CMD_HEADER( Rivet_UrlScript ) if (entry == NULL) { Tcl_Interp* interp; - + interp = rivet_interp->interp; script = Tcl_NewObj(); @@ -1976,11 +1976,11 @@ TCL_CMD_HEADER( Rivet_UrlScript ) Tcl_HashEntry* entry; entry = RivetCache_CreateEntry (rivet_interp,cache_key,&isNew); - + /* Sanity check: we are here for this reason */ ap_assert(isNew == 1); - + /* we proceed storing the script in the cache */ RivetCache_StoreScript(rivet_interp,entry,script); @@ -2011,7 +2011,7 @@ TCL_CMD_HEADER( Rivet_UrlScript ) * With a threaded bridge (worker and lazy) command [pid] on Unix systems return * the same process id when called from all threads running within that process. * For any debugging reason this command returns a unique thread identification - * that can, for instance, be matched with the thread id (tid) information + * that can, for instance, be matched with the thread id (tid) information * in the error log file. * * Arguments: @@ -2068,7 +2068,7 @@ TCL_CMD_HEADER( Rivet_GetThreadId ) Tcl_AddObjErrorInfo(interp,"Wrong argument: it must be -decimal | -hex", -1); return TCL_ERROR; } - } + } else if (objc > 2) { Tcl_WrongNumArgs(interp,1,objv,"-decimal | -hex" ); @@ -2095,7 +2095,7 @@ TCL_CMD_HEADER( Rivet_GetThreadId ) * documented within the 'Rivet Internals' section of the manual * * Results: - * + * * a Tcl list of the keys in the interpreter cache * * Side Effects: @@ -2116,12 +2116,12 @@ TCL_CMD_HEADER( Rivet_CacheContent ) rivet_interp = RIVET_PEEK_INTERP(private,private->running_conf); interp = rivet_interp->interp; - + entry_list = Tcl_NewObj(); Tcl_IncrRefCount(entry_list); ep = rivet_interp->cache_size - 1; - + while ((ep >= 0) && (rivet_interp->objCacheList[ep])) { int tcl_status; @@ -2161,7 +2161,7 @@ DLLEXPORT int Rivet_InitCore(rivet_thread_interp* interp_obj,rivet_thread_private* private) { Tcl_Interp* interp = interp_obj->interp; - rivet_server_conf* server_conf; + rivet_server_conf* server_conf; RIVET_OBJ_CMD ("makeurl",Rivet_MakeURL,private); RIVET_OBJ_CMD ("headers",Rivet_Headers,private); @@ -2185,7 +2185,7 @@ Rivet_InitCore(rivet_thread_interp* interp_obj,rivet_thread_private* private) RIVET_OBJ_CMD ("exit",Rivet_ExitCmd,private); RIVET_OBJ_CMD ("url_script",Rivet_UrlScript,private); RIVET_OBJ_CMD ("thread_id",Rivet_GetThreadId,private); - + #ifdef RIVET_DEBUG_BUILD /* code compiled conditionally for debugging */ RIVET_OBJ_CMD ("cache_content",Rivet_CacheContent,private); diff --git a/src/mod_rivet_ng/rivetInspect.c b/src/mod_rivet_ng/rivetInspect.c index bc0e63e..cb4bc51 100644 --- a/src/mod_rivet_ng/rivetInspect.c +++ b/src/mod_rivet_ng/rivetInspect.c @@ -52,9 +52,9 @@ static const char* loglevel_defs[] = /* These arrays must be kept aligned. confDirectives must be NULL terminated */ -static const char* confDirectives[] = -{ - "ServerInitScript", +static const char* confDirectives[] = +{ + "ServerInitScript", "GlobalInitScript", "ChildInitScript", "ChildExitScript", @@ -74,7 +74,7 @@ static const char* confDirectives[] = "ExportRivetNS", "ImportRivetNS", "SingleThreadExit", - NULL + NULL }; enum confIndices { @@ -98,18 +98,18 @@ enum confIndices { export_rivet_ns, import_rivet_ns, single_thread_exit, - conf_index_terminator + conf_index_terminator }; extern mod_rivet_globals* module_globals; -/* +/* * -- Rivet_ReadConfParameter * - * This procedure reads a single field named par_name from + * This procedure reads a single field named par_name from * rivet_server_conf structure and returns a Tcl_Obj pointer * containing the field value. See confDirectives for a list - * of possible names. If the procedure is queried for a non + * of possible names. If the procedure is queried for a non * existing field a NULL is returned. * * Arguments: @@ -133,7 +133,7 @@ Rivet_ReadConfParameter ( Tcl_Interp* interp, Tcl_Obj* par_name) { int parameter_i; - Tcl_Obj* int_value = NULL; + Tcl_Obj* int_value = NULL; char* string_value = NULL; if (Tcl_GetIndexFromObj(interp, par_name, confDirectives, @@ -183,7 +183,7 @@ Rivet_ReadConfParameter ( Tcl_Interp* interp, /* otherwise if string_value is defined we return it as Tcl_Obj*/ return Tcl_NewStringObj(string_value,-1); - } + } else { /* there is no other possible case: int_value must be returned */ @@ -193,11 +193,11 @@ Rivet_ReadConfParameter ( Tcl_Interp* interp, } -/* - * Rivet_ReadConfTable: - * +/* + * Rivet_ReadConfTable: + * * This procedure builds a key-value list from an apr table - * It's called by Rivet_BuildConfDictionary to read theRivet + * It's called by Rivet_BuildConfDictionary to read theRivet * configuration tables but it can work for every apr table * * Arguments: @@ -207,7 +207,7 @@ Rivet_ReadConfParameter ( Tcl_Interp* interp, * */ -static Tcl_Obj* +static Tcl_Obj* Rivet_ReadConfTable (Tcl_Interp* interp, apr_table_t* table) { @@ -232,7 +232,7 @@ Rivet_ReadConfTable (Tcl_Interp* interp, tcl_status = Tcl_ListObjAppendElement (interp,keyval_list,key); if (tcl_status == TCL_ERROR) - { + { Tcl_DecrRefCount(keyval_list); Tcl_DecrRefCount(key); Tcl_DecrRefCount(val); @@ -258,9 +258,9 @@ Rivet_ReadConfTable (Tcl_Interp* interp, /* * -- Rivet_BuildConfDictionary - * + * * Parameters set in the configuration files are collected in three - * APR tables by Rivet_ServerConf,Rivet_DirConf and Rivet_UserConf. + * APR tables by Rivet_ServerConf,Rivet_DirConf and Rivet_UserConf. * * Arguments: * @@ -271,7 +271,7 @@ Rivet_ReadConfTable (Tcl_Interp* interp, * Returned value: * * - Tcl dictionary storing the dir/user/server configuration. The - * dictionary refCount is incremented + * dictionary refCount is incremented * */ @@ -284,7 +284,7 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl_Interp* interp, int it; Tcl_Obj* conf_dict = Tcl_NewObj(); - static const char* section_names[] = + static const char* section_names[] = { "dir", "user", @@ -314,7 +314,7 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl_Interp* interp, Tcl_Obj** objArrayPnt; int objArrayCnt; Tcl_Obj* val; - + Tcl_IncrRefCount(keyval_list); key_list[0] = Tcl_NewStringObj(section_names[it],-1); @@ -348,7 +348,7 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl_Interp* interp, /* - * Rivet_CurrentConfDict + * Rivet_CurrentConfDict * * This function is called by Rivet_InspectCmd which implements command * '::rivet::inspect -all'. The function returns a dictionary where every @@ -364,14 +364,14 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl_Interp* interp, * * - a Tcl_Obj* pointer to a dictionary. The function is guaranteed to * return a Tcl_Obj pointer - * + * */ Tcl_Obj* Rivet_CurrentConfDict ( Tcl_Interp* interp, rivet_server_conf* rivet_conf) { Tcl_Obj* dictObj = Tcl_NewObj(); - Tcl_Obj* par_name; + Tcl_Obj* par_name; const char** p; for (p = confDirectives; (*p) != NULL; p++) @@ -397,19 +397,19 @@ Tcl_Obj* Rivet_CurrentConfDict ( Tcl_Interp* interp, /* * -- Rivet_CurrentServerRec * - * ::rivet::inspect provides also some basic access to + * ::rivet::inspect provides also some basic access to * fields of the server_rec object. * - * + * */ -Tcl_Obj* +Tcl_Obj* Rivet_CurrentServerRec (Tcl_Interp* interp, server_rec* s ) { - Tcl_Obj* dictObj; + Tcl_Obj* dictObj; Tcl_Obj* field_name; Tcl_Obj* field_value; - + dictObj = Tcl_NewObj(); field_value = Tcl_NewStringObj(s->server_hostname,-1); diff --git a/src/mod_rivet_ng/rivet_lazy_mpm.c b/src/mod_rivet_ng/rivet_lazy_mpm.c index c295833..651a70a 100644 --- a/src/mod_rivet_ng/rivet_lazy_mpm.c +++ b/src/mod_rivet_ng/rivet_lazy_mpm.c @@ -96,7 +96,7 @@ enum { #define MOD_RIVET_QUEUE_SIZE 100 /* - * -- Rivet_ExecutionThreadInit + * -- Rivet_ExecutionThreadInit * * We keep here the basic initilization each execution thread should undergo * @@ -122,10 +122,10 @@ static rivet_thread_private* Rivet_ExecutionThreadInit (apr_thread_t *thd) static void Lazy_RunConfScript (rivet_thread_private* private,lazy_tcl_worker* w,int init) { - Tcl_Obj* tcl_conf_script; + Tcl_Obj* tcl_conf_script; Tcl_Interp* interp = private->ext->interp->interp; void* function = NULL; - + switch (init) { case child_global: function = w->conf->rivet_global_init_script; @@ -140,16 +140,16 @@ static void Lazy_RunConfScript (rivet_thread_private* private,lazy_tcl_worker* w tcl_conf_script = Tcl_NewStringObj(function,-1); Tcl_IncrRefCount(tcl_conf_script); - if (Tcl_EvalObjEx(interp,tcl_conf_script, 0) != TCL_OK) + if (Tcl_EvalObjEx(interp,tcl_conf_script, 0) != TCL_OK) { char* errmsg = "rivet_lazy_mpm.so: Error in configuration script: %s"; server_rec* root_server = module_globals->server; ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL,root_server, errmsg, function); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL,root_server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL,root_server, "errorCode: %s", Tcl_GetVar(interp, "errorCode", 0)); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL,root_server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL,root_server, "errorInfo: %s", Tcl_GetVar(interp, "errorInfo", 0)); } @@ -160,16 +160,16 @@ static void Lazy_RunConfScript (rivet_thread_private* private,lazy_tcl_worker* w /* * -- request_processor * - * The lazy bridge worker thread. This thread prepares its control data and + * The lazy bridge worker thread. This thread prepares its control data and * will serve requests addressed to a given virtual host. Virtual host server - * data are stored in the lazy_tcl_worker structure stored in the generic + * data are stored in the lazy_tcl_worker structure stored in the generic * pointer argument 'data' - * + * */ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) { - lazy_tcl_worker* w = (lazy_tcl_worker*) data; + lazy_tcl_worker* w = (lazy_tcl_worker*) data; rivet_thread_private* private; int idx; rivet_server_conf* rsc; @@ -183,7 +183,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) private = Rivet_ExecutionThreadInit(thd); /* A bridge creates and stores in private->ext its own thread private - * data. The lazy bridge is no exception. We just need a flag controlling + * data. The lazy bridge is no exception. We just need a flag controlling * the execution and an intepreter control structure */ private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific)); @@ -193,8 +193,8 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) //RIVET_POKE_INTERP(private,rsc,Rivet_NewVHostInterp(private,w->server)); private->ext->interp->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key); - /* The worker thread can respond to a single - * request at a time therefore must handle and + /* The worker thread can respond to a single + * request at a time therefore must handle and * register its own Rivet channel */ Tcl_RegisterChannel(private->ext->interp->interp,*private->ext->interp->channel); @@ -202,14 +202,14 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) /* From the rivet_server_conf structure we determine what scripts we * are using to serve requests */ - private->ext->interp->scripts = + private->ext->interp->scripts = Rivet_RunningScripts (private->pool,private->ext->interp->scripts,rsc); /* This is the standard Tcl interpreter initialization */ Rivet_PerInterpInit(private->ext->interp,private,w->server,private->pool); - - /* The child initialization is fired. Beware of the terminologic + + /* The child initialization is fired. Beware of the terminologic * trap: we inherited from fork capable systems the term 'child' * meaning 'child process'. In this case the child init actually * is a worker thread initialization, because in a threaded module @@ -218,7 +218,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) Lazy_RunConfScript(private,w,child_init); - /* The thread is now set up to serve request within the the + /* The thread is now set up to serve request within the the * do...while loop controlled by private->keep_going */ idx = w->conf->idx; @@ -229,11 +229,11 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) apr_thread_mutex_lock(w->mutex); ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,w->server,"processor thread startup completed"); - do + do { while ((w->status != init) && (w->status != thread_exit)) { apr_thread_cond_wait(w->condition,w->mutex); - } + } if (w->status == thread_exit) { private->ext->keep_going = 0; continue; @@ -254,10 +254,10 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) apr_thread_cond_signal(w->condition); while (w->status == done) { apr_thread_cond_wait(w->condition,w->mutex); - } - + } + /* rescheduling itself in the array of idle threads */ - + if (private->ext->keep_going) { apr_thread_mutex_lock(module_globals->mpm->vhosts[idx].mutex); @@ -271,14 +271,14 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) } while (private->ext->keep_going); apr_thread_mutex_unlock(w->mutex); - + Lazy_RunConfScript(private,w,child_exit); Rivet_ReleaseRunningScripts(private->ext->interp->scripts); /* If single thread exit is enabled we delete the Tcl interp */ - if (!module_globals->single_thread_exit) + if (!module_globals->single_thread_exit) { Tcl_DeleteInterp(private->ext->interp->interp); } @@ -308,7 +308,7 @@ static lazy_tcl_worker* create_worker (apr_pool_t* pool,server_rec* server) w->status = idle; w->server = server; ap_assert(apr_thread_mutex_create(&w->mutex,APR_THREAD_MUTEX_UNNESTED,pool) == APR_SUCCESS); - ap_assert(apr_thread_cond_create(&w->condition, pool) == APR_SUCCESS); + ap_assert(apr_thread_cond_create(&w->condition, pool) == APR_SUCCESS); apr_thread_create(&w->thread_id, NULL, request_processor, w, module_globals->pool); return w; @@ -316,7 +316,7 @@ static lazy_tcl_worker* create_worker (apr_pool_t* pool,server_rec* server) /* * -- LazyBridge_ChildInit - * + * * child process initialization. This function prepares the process * data structures for virtual hosts and threads management * @@ -336,13 +336,13 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server) /* This mutex is only used to consistently carry out modifications * on the module_globals structure that may result in inconsitent - * status due to concurrent access. + * status due to concurrent access. * - * - set the exit status of a child process (hopefully will be - * unnecessary when Tcl is able again of calling - * Tcl_DeleteInterp safely) + * - set the exit status of a child process (hopefully will be + * unnecessary when Tcl is able again of calling + * Tcl_DeleteInterp safely) * - control the server_shutdown flag. Actually this is - * not entirely needed because once set this flag + * not entirely needed because once set this flag * is never reset to 0 * - create thread specific pools of memory * @@ -354,7 +354,7 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server) /* the mpm->vhosts array is created with as many entries as the number of * configured virtual hosts */ - module_globals->mpm->vhosts = + module_globals->mpm->vhosts = (vhost *) apr_pcalloc(pool,module_globals->vhosts_count*sizeof(vhost)); ap_assert(module_globals->mpm->vhosts != NULL); @@ -362,7 +362,7 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server) * Each virtual host descriptor has its own mutex controlling * the queue of available threads */ - + for (s = root_server; s != NULL; s = s->next) { int vh; @@ -382,7 +382,7 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server) /* -- LazyBridge_Request * - * The lazy bridge HTTP request function. This function + * The lazy bridge HTTP request function. This function * stores the request_rec pointer into the lazy_tcl_worker * structure which is used to communicate with a worker thread. * Then the array of idle threads is checked and if empty @@ -401,11 +401,11 @@ int LazyBridge_Request (request_rec* r,rivet_req_ctype ctype) array = module_globals->mpm->vhosts[conf->idx].array; apr_thread_mutex_lock(mutex); - /* This request may have come while the child process was - * shutting down. We cannot run the risk that incoming requests - * may hang the child process by keeping its threads busy, - * so we simply return an HTTP_INTERNAL_SERVER_ERROR. - * This is hideous and explains why the 'exit' commands must + /* This request may have come while the child process was + * shutting down. We cannot run the risk that incoming requests + * may hang the child process by keeping its threads busy, + * so we simply return an HTTP_INTERNAL_SERVER_ERROR. + * This is hideous and explains why the 'exit' commands must * be avoided at any costs when programming with mod_rivet */ @@ -429,7 +429,7 @@ int LazyBridge_Request (request_rec* r,rivet_req_ctype ctype) apr_thread_mutex_unlock(mutex); - /* Locking the thread descriptor structure mutex */ + /* Locking the thread descriptor structure mutex */ apr_thread_mutex_lock(w->mutex); w->r = r; @@ -442,7 +442,7 @@ int LazyBridge_Request (request_rec* r,rivet_req_ctype ctype) while (w->status != done) { apr_thread_cond_wait(w->condition,w->mutex); - } + } ap_sts = w->ap_sts; w->status = idle; @@ -478,7 +478,7 @@ apr_status_t LazyBridge_Finalize (void* data) int idx; server_rec* server = (server_rec*) data; rivet_server_conf* conf = RIVET_SERVER_CONF(server->module_config); - + module_globals->mpm->server_shutdown = 1; for (idx = 0; idx < module_globals->vhosts_count; idx++) { @@ -499,7 +499,7 @@ apr_status_t LazyBridge_Finalize (void* data) while ((try++ < 3) && (count > 0)) { ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,server,"waiting for %d thread to exit",count); - if ((conf->idx == idx) && (count == 1)) { break; } + if ((conf->idx == idx) && (count == 1)) { break; } /* if ap_child_shutdown is set the child exit was triggered * by the apache framework and this function is running @@ -508,14 +508,14 @@ apr_status_t LazyBridge_Finalize (void* data) * the last thread remaining in the worker thread pool */ - if (!module_globals->ap_child_shutdown && - (conf->idx == idx) && (count == 1)) { break; } + if (!module_globals->ap_child_shutdown && + (conf->idx == idx) && (count == 1)) { break; } - while (!apr_is_empty_array(array)) + while (!apr_is_empty_array(array)) { lazy_tcl_worker* w; - w = *(lazy_tcl_worker**) apr_array_pop(array); + w = *(lazy_tcl_worker**) apr_array_pop(array); apr_thread_mutex_lock(w->mutex); w->r = NULL; w->status = thread_exit; @@ -538,7 +538,7 @@ apr_status_t LazyBridge_Finalize (void* data) int LazyBridge_ExitHandler(rivet_thread_private* private) { - /* This is not strictly necessary, because this command will + /* This is not strictly necessary, because this command will * eventually terminate the whole processes */ /* This will force the current thread to exit */ @@ -547,13 +547,13 @@ int LazyBridge_ExitHandler(rivet_thread_private* private) if (!module_globals->single_thread_exit) { - /* We now tell the supervisor to terminate the Tcl worker + /* We now tell the supervisor to terminate the Tcl worker * thread pool to exit and is sequence the whole process * to shutdown by calling exit() */ - + LazyBridge_Finalize(private->r->server); - } + } return TCL_OK; } @@ -563,7 +563,7 @@ int LazyBridge_ExitHandler(rivet_thread_private* private) * * Bridge server wide inizialization: * - * We set the default value of the flag single_thread_exit + * We set the default value of the flag single_thread_exit * stored in the module globals * */ diff --git a/src/mod_rivet_ng/rivet_prefork_mpm.c b/src/mod_rivet_ng/rivet_prefork_mpm.c index eac1d55..c65257d 100644 --- a/src/mod_rivet_ng/rivet_prefork_mpm.c +++ b/src/mod_rivet_ng/rivet_prefork_mpm.c @@ -45,7 +45,7 @@ extern TclWebRequest* TclWeb_NewRequestObject (apr_pool_t *p); * */ -int PreforkBridge_ServerInit (apr_pool_t *pPool, +int PreforkBridge_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *server) { @@ -81,7 +81,7 @@ int PreforkBridge_ServerInit (apr_pool_t *pPool, * in that context. We create the cache now */ if (module_globals->server_interps[server_idx]->cache_size) { - RivetCache_Create(module_globals->server_interps[server_idx]); + RivetCache_Create(module_globals->server_interps[server_idx]); } /* @@ -98,7 +98,7 @@ int PreforkBridge_ServerInit (apr_pool_t *pPool, rsc = RIVET_SERVER_CONF(s->module_config); idx = rsc->idx; - /* + /* * travelling the servers records. We create a new interpreter * if not created by Rivet_ServerInit */ @@ -116,7 +116,7 @@ int PreforkBridge_ServerInit (apr_pool_t *pPool, } } } - + return OK; } @@ -148,7 +148,7 @@ static void Prefork_ReseedRNG(server_rec* server,rivet_thread_interp* interp_obj tcl_status = Tcl_Eval(interp_obj->interp,"expr {srand([clock clicks] + [pid])}"); if (tcl_status != TCL_OK) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": Tcl interpreter random number generation reseeding failed"); } @@ -159,7 +159,7 @@ static void Prefork_ReseedRNG(server_rec* server,rivet_thread_interp* interp_obj void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server) { rivet_thread_private* private; - rivet_server_conf* root_server_conf; + rivet_server_conf* root_server_conf; rivet_thread_interp** server_interps = module_globals->server_interps; RIVET_PRIVATE_DATA_NOT_NULL(rivet_thread_key,private) @@ -170,23 +170,23 @@ void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server) private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific)); - /* Prefork bridge has inherited the parent process pool but we have - * to initialize ourselves the request descriptor obj + /* Prefork bridge has inherited the parent process pool but we have + * to initialize ourselves the request descriptor obj */ private->req = TclWeb_NewRequestObject(private->pool); - /* The prefork MPM just needs to keep a pointer + /* The prefork MPM just needs to keep a pointer * to the interpreters array in module_globals->server_interps */ - private->ext->interps = module_globals->server_interps; + private->ext->interps = module_globals->server_interps; /* reseeding the RNG for each interpreter when a new child process is created */ RIVET_FOREACH_SERVER(server,server_interps,Prefork_ReseedRNG) - if (root_server_conf->rivet_global_init_script != NULL) + if (root_server_conf->rivet_global_init_script != NULL) { Tcl_Obj* global_tcl_script; @@ -199,7 +199,7 @@ void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server) } /* This step is not needed anymore, we rely on the initialization that took - * place with the server initialization + * place with the server initialization */ /* we now establish the full rivet core command set for the root interpreter */ @@ -210,7 +210,7 @@ void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server) RIVET_FOREACH_SERVER(server,server_interps,Rivet_ImportNamespace) -#endif +#endif /* * We proceed creating the whole virtual host interpreters array @@ -218,7 +218,7 @@ void PreforkBridge_ChildInit (apr_pool_t* pool, server_rec* server) if (Rivet_SetupInterps(private) == NULL) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": Tcl Interpreters creation fails"); exit(1); } @@ -269,16 +269,16 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* server) * of the process, math engine status included. This fact implies * the random number generator has the same seed and every * child process for which SeparateVirtualInterps would generate - * the same random number sequence. We therefore reseed the RNG + * the same random number sequence. We therefore reseed the RNG * calling a Tcl script fragment */ tcl_status = Tcl_Eval(module_globals->server_interps[0]->interp,"expr {srand([clock clicks] + [pid])}"); if (tcl_status != TCL_OK) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": Tcl interpreter random number generation reseeding failed"); - + } return module_globals->server_interps[0]; } @@ -287,14 +287,14 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* server) /* * -- PreforkBridge_ExitHandler * - * Just calling Tcl_Exit + * Just calling Tcl_Exit * * Arguments: * int code * * Side Effects: * - * the thread running the Tcl script will exit + * the thread running the Tcl script will exit */ int PreforkBridge_ExitHandler(rivet_thread_private* private) @@ -302,7 +302,7 @@ int PreforkBridge_ExitHandler(rivet_thread_private* private) Tcl_Exit(private->exit_status); /* actually we'll never get here but we return - * the Tcl return code anyway to silence the + * the Tcl return code anyway to silence the * compilation warning */ return TCL_OK; @@ -314,7 +314,7 @@ rivet_thread_interp* PreforkBridge_Interp (rivet_thread_private* private, { if (interp != NULL) { private->ext->interps[conf->idx] = interp; } - return private->ext->interps[conf->idx]; + return private->ext->interps[conf->idx]; } /* Table of bridge control functions */ diff --git a/src/mod_rivet_ng/rivet_types.h b/src/mod_rivet_ng/rivet_types.h index 4f4fd23..69a9a4a 100644 --- a/src/mod_rivet_ng/rivet_types.h +++ b/src/mod_rivet_ng/rivet_types.h @@ -29,7 +29,7 @@ /* Definition suggested in * - * https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Particular-Headers.html + * https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Particular-Headers.html * * in order to have a portable definition of the 'bool' data type */ diff --git a/src/mod_rivet_ng/rivet_worker_mpm.c b/src/mod_rivet_ng/rivet_worker_mpm.c index 5eed91d..887ef67 100644 --- a/src/mod_rivet_ng/rivet_worker_mpm.c +++ b/src/mod_rivet_ng/rivet_worker_mpm.c @@ -80,12 +80,12 @@ typedef struct mpm_bridge_status { } mpm_bridge_status; -/* +/* * data structure to work as communication - * between Tcl worker thread and HTTP request handler - */ + * between Tcl worker thread and HTTP request handler + */ -typedef struct _handler_private +typedef struct _handler_private { apr_thread_cond_t* cond; apr_thread_mutex_t* mutex; @@ -105,21 +105,21 @@ enum child_exit }; -/* +/* * -- Worker_Bridge_Shutdown * * Child process shutdown: no more requests are served and we - * pop from the queue all the threads sitting for work to do. + * pop from the queue all the threads sitting for work to do. * In case some Tcl worker threads are still running and don't * get back to the queue we wait for 1 sec max before returning - * anyway + * anyway * * Arguments: * * none * * Returned value: - * + * * none * * Side effects: @@ -143,7 +143,7 @@ void Worker_Bridge_Shutdown (void) module_globals->mpm->server_shutdown = 1; - /* We wake up the supervisor who is now supposed to stop + /* We wake up the supervisor who is now supposed to stop * all the Tcl worker threads */ @@ -161,7 +161,7 @@ void Worker_Bridge_Shutdown (void) * see the signal yet */ - if (rv == APR_EAGAIN) + if (rv == APR_EAGAIN) { waits--; apr_sleep(200000); @@ -202,7 +202,7 @@ void Worker_Bridge_Shutdown (void) * see the signal */ - if (rv == APR_EAGAIN) + if (rv == APR_EAGAIN) { waits--; apr_sleep(200000); @@ -237,7 +237,7 @@ static void Worker_CreateInterps (rivet_thread_private* private,rivet_thread_int { rivet_server_conf* server_conf; rivet_thread_interp* root_interp = NULL; - + server_conf = RIVET_SERVER_CONF(s->module_config); if ((s == server) || (module_globals->separate_virtual_interps)) @@ -249,7 +249,7 @@ static void Worker_CreateInterps (rivet_thread_private* private,rivet_thread_int } else { - interp_obj = + interp_obj = Rivet_DuplicateVHostInterp(private->pool,root_interp); } @@ -286,15 +286,15 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific)); private->ext->keep_going = 1; - private->ext->interps = + private->ext->interps = apr_pcalloc(private->pool,module_globals->vhosts_count*sizeof(rivet_thread_interp)); /* We need to create the thread's interpreters */ Worker_CreateInterps (private,private->ext->interps); - /* At this stage we have to set up the private interpreters of configured - * virtual hosts (if any). + /* At this stage we have to set up the private interpreters of configured + * virtual hosts (if any). */ if (Rivet_SetupInterps(private) == NULL) @@ -310,7 +310,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) thread_obj = apr_pcalloc(private->pool,sizeof(handler_private)); ap_assert(apr_thread_cond_create(&(thread_obj->cond), private->pool) == APR_SUCCESS); - ap_assert(apr_thread_mutex_create(&(thread_obj->mutex),APR_THREAD_MUTEX_UNNESTED,private->pool) + ap_assert(apr_thread_mutex_create(&(thread_obj->mutex),APR_THREAD_MUTEX_UNNESTED,private->pool) == APR_SUCCESS); thread_obj->status = idle; @@ -331,7 +331,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) { private->ext->keep_going = 0; continue; - } + } /* The request handler must change the status to init and then notify the thread * to wake up and proceed with the request processing @@ -353,7 +353,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) thread_obj->status = request_processing; /* we proceed with the request processing */ - + apr_atomic_inc32(module_globals->mpm->running_threads_count); /* these assignements are crucial for both calling Rivet_SendContent and @@ -428,16 +428,16 @@ static void start_thread_pool (int nthreads) { apr_status_t rv; apr_thread_t* slot; - + rv = create_worker_thread(&slot); module_globals->mpm->workers[i] = (void *) slot; - if (rv != APR_SUCCESS) + if (rv != APR_SUCCESS) { char errorbuf[RIVET_MSG_BUFFER_SIZE]; apr_strerror(rv, errorbuf,RIVET_MSG_BUFFER_SIZE); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, "Error starting request_processor thread (%d) rv=%d:%s\n",i,rv,errorbuf); exit(1); @@ -473,10 +473,10 @@ static void supervisor_housekeeping (void) /* -- threaded_bridge_supervisor - * + * * This function runs within a single thread and to the * start and stop of Tcl worker thread pool. It could be extended also - * provide some basic monitoring data. + * provide some basic monitoring data. * * As we don't delete Tcl interpreters anymore because it can lead * to seg faults or delays the supervisor threads doesn't restart @@ -490,7 +490,7 @@ static void supervisor_housekeeping (void) static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void *data) { mpm_bridge_status* mpm = module_globals->mpm; - server_rec* s; + server_rec* s; #ifdef RIVET_MPM_SINGLE_TCL_THREAD int threads_to_start = 1; @@ -517,7 +517,7 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void apr_thread_t* p; p = *(apr_thread_t **)apr_array_pop(mpm->exiting); - + for (i = 0; (i < module_globals->mpm->max_threads) && !mpm->server_shutdown; i++) { if (p == mpm->workers[i]) @@ -539,16 +539,16 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void */ apr_strerror(rv,errorbuf,RIVET_MSG_BUFFER_SIZE); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, "Error starting request_processor thread (%d) rv=%d:%s",i,rv,errorbuf); exit(1); } - + break; } - } - } + } + } apr_thread_mutex_unlock(mpm->job_mutex); } while (!mpm->server_shutdown); @@ -562,12 +562,12 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void * -- Worker_Bridge_ChildInit * * Child initialization function called by the web server framework. - * For this bridge tasks are + * For this bridge tasks are * * + mpm_bridge_status object allocation and initialization * + content generation callback private key creation * + supervisor thread creation - * + * */ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) @@ -581,7 +581,7 @@ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) /* On some plattform this is required in order to initialize * APR atomic function utilities */ - + apr_atomic_init(pool); #ifdef RIVET_SERIALIZE_HTTP_REQUESTS @@ -604,7 +604,7 @@ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) module_globals->mpm->server_shutdown = 0; //module_globals->mpm->exit_command = 0; module_globals->mpm->skip_thread_on_exit = 0; - + /* We keep some atomic counters that could provide basic data for a workload balancer */ module_globals->mpm->threads_count = (apr_uint32_t *) apr_pcalloc(pool,sizeof(apr_uint32_t)); @@ -624,13 +624,13 @@ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) if (apr_queue_create(&module_globals->mpm->queue, MOD_RIVET_QUEUE_SIZE, module_globals->pool) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, MODNAME ": could not initialize mod_rivet request queue"); exit(1); } /* In order to set up some data for workload balancer we - * query apache about some configuration parameters of the worker MPM + * query apache about some configuration parameters of the worker MPM */ if (ap_mpm_query(AP_MPMQ_MAX_THREADS,&module_globals->mpm->max_threads) != APR_SUCCESS) @@ -658,14 +658,14 @@ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) /* thread arguments pass the master server record and the process pool */ - rv = apr_thread_create(&module_globals->mpm->supervisor,NULL, + rv = apr_thread_create(&module_globals->mpm->supervisor,NULL, threaded_bridge_supervisor,NULL,pool); if (rv != APR_SUCCESS) { char errorbuf[RIVET_MSG_BUFFER_SIZE]; apr_strerror(rv, errorbuf,RIVET_MSG_BUFFER_SIZE); - ap_log_error(APLOG_MARK, APLOG_ERR, rv, server, + ap_log_error(APLOG_MARK, APLOG_ERR, rv, server, MODNAME "Error starting supervisor thread rv=%d:%s\n",rv,errorbuf); exit(1); } @@ -682,7 +682,7 @@ void Worker_Bridge_ChildInit (apr_pool_t* pool, server_rec* server) * * void* client_data: a generic pointer cast to a handler_private object pointer * - */ + */ apr_status_t Worker_RequestPrivateCleanup (void *client_data) { @@ -703,10 +703,10 @@ apr_status_t Worker_RequestPrivateCleanup (void *client_data) * -- Worker_Bridge_Request * * Content generation callback. Actually this function is not - * generating directly content but instead builds a handler_private - * structure, which is a descriptor of the request to be placed on a - * global thread safe queue (module_globals->mpm->queue). In this structure - * are also a condition variable and associated mutex. Through this + * generating directly content but instead builds a handler_private + * structure, which is a descriptor of the request to be placed on a + * global thread safe queue (module_globals->mpm->queue). In this structure + * are also a condition variable and associated mutex. Through this * condition variable a worker thread running a Tcl interpreter will tell * the framework thread the request has been served letting it return to the * HTTP server framework @@ -727,10 +727,10 @@ int Worker_Bridge_Request (request_rec* r,rivet_req_ctype ctype) apr_status_t rv; handler_private* request_obj; int http_code; - + if (module_globals->mpm->server_shutdown == 1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, MODNAME ": http request aborted during child process shutdown"); return HTTP_INTERNAL_SERVER_ERROR; @@ -750,7 +750,7 @@ int Worker_Bridge_Request (request_rec* r,rivet_req_ctype ctype) return HTTP_INTERNAL_SERVER_ERROR; } - + request_obj = (handler_private *) v; apr_thread_mutex_lock(request_obj->mutex); @@ -769,14 +769,14 @@ int Worker_Bridge_Request (request_rec* r,rivet_req_ctype ctype) http_code = request_obj->code; request_obj->status = idle; - + apr_thread_cond_signal(request_obj->cond); apr_thread_mutex_unlock(request_obj->mutex); return http_code; } -/* +/* * -- Worker_Bridge_Finalize * * @@ -801,7 +801,7 @@ apr_status_t Worker_Bridge_Finalize (void* data) /* * -- Worker_Bridge_ExitHandler - * + * * Signals a thread to exit by setting the loop control flag to 0 * and by returning a Tcl error with error code THREAD_EXIT_CODE * @@ -811,12 +811,12 @@ apr_status_t Worker_Bridge_Finalize (void* data) * * Side Effects: * - * the thread running the Tcl script will exit + * the thread running the Tcl script will exit */ int Worker_Bridge_ExitHandler(rivet_thread_private* private) { - /* This is not strictly necessary, because this command will + /* This is not strictly necessary, because this command will * eventually terminate the whole processes */ /* This will force the current thread to exit */ @@ -832,11 +832,11 @@ int Worker_Bridge_ExitHandler(rivet_thread_private* private) /* We now tell the supervisor to terminate the Tcl worker thread pool to exit * and is sequence the whole process to shutdown by calling exit() */ - + Worker_Bridge_Finalize (private->r->server); - + exit(private->exit_status); - } + } /* * If single thread exit is enabled we continue and let the @@ -852,7 +852,7 @@ rivet_thread_interp* Worker_Bridge_Interp (rivet_thread_private* private, { if (interp != NULL) { private->ext->interps[conf->idx] = interp; } - return private->ext->interps[conf->idx]; + return private->ext->interps[conf->idx]; } DLLEXPORT diff --git a/src/mod_rivet_ng/worker_prefork_common.c b/src/mod_rivet_ng/worker_prefork_common.c index 2f1ee3f..18f7e5c 100644 --- a/src/mod_rivet_ng/worker_prefork_common.c +++ b/src/mod_rivet_ng/worker_prefork_common.c @@ -51,11 +51,11 @@ extern DLLIMPORT module rivet_module; * Returned value: * * a new rivet_thread_private object - * + * * Side effects: * * GlobalInitScript and ChildInitScript are run at this stage - * + * */ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) @@ -71,7 +71,7 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key); /* The intepreters were created by the server init script, we now create its Rivet channel - * We assume the server_rec stored in the module globals can be used to retrieve the + * We assume the server_rec stored in the module globals can be used to retrieve the * reference to the root interpreter configuration and to the rivet global script */ @@ -79,18 +79,18 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) for (s = root_server; s != NULL; s = s->next) { - rivet_server_conf* rsc; - rivet_thread_interp* interp_obj; - + rivet_server_conf* rsc; + rivet_thread_interp* interp_obj; + rsc = RIVET_SERVER_CONF(s->module_config); interp_obj = private->ext->interps[rsc->idx]; if ((s != root_server) && - module_globals->separate_channels && + module_globals->separate_channels && module_globals->separate_virtual_interps) { channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key); - } + } interp_obj->channel = channel; Tcl_RegisterChannel(interp_obj->interp,*channel); @@ -113,7 +113,7 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) /* when configured a child init script gets evaluated */ function = rsc->rivet_child_init_script; - if (function && + if (function && (s == root_server || module_globals->separate_virtual_interps || function != parentfunction)) { char* errmsg = MODNAME ": Error in Child init script: %s"; @@ -127,9 +127,9 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) if (Tcl_EvalObjEx(interp,tcl_child_init, 0) != TCL_OK) { ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, errmsg, function); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, "errorCode: %s", Tcl_GetVar(interp, "errorCode", 0)); - ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, + ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, "errorInfo: %s", Tcl_GetVar(interp, "errorInfo", 0)); } Tcl_Release (interp); @@ -142,7 +142,7 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) /* * -- Rivet_ProcessorCleanup * - * Thread private data cleanup. This function was meant to be + * Thread private data cleanup. This function was meant to be * called by the worker and prefork MPM bridges to release resources * owned by thread private data and pointed in the array of rivet_thread_interp * objects. It has to be called just before an agent, either thread or @@ -151,7 +151,7 @@ rivet_thread_private* Rivet_SetupInterps (rivet_thread_private* private) * * Arguments: * - * data: pointer to a rivet_thread_private data structure. + * data: pointer to a rivet_thread_private data structure. * * Returned value: * @@ -170,11 +170,11 @@ void Rivet_ProcessorCleanup (rivet_thread_private* private) server_rec* s; server_rec* server; - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, module_globals->server, - "Thread exiting after %d requests served (%d vhosts)", + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, module_globals->server, + "Thread exiting after %d requests served (%d vhosts)", private->req_cnt,module_globals->vhosts_count); - /* We are about to delete the interpreters and release the thread channel. + /* We are about to delete the interpreters and release the thread channel. * Rivet channel is set as stdout channel of Tcl and as such is treated * by Tcl_UnregisterChannel is a special way. When its refCount reaches 1 * the channel is released immediately by forcing the refCount to 0 @@ -186,7 +186,7 @@ void Rivet_ProcessorCleanup (rivet_thread_private* private) Tcl_SetStdChannel(NULL,TCL_STDOUT); /* there must be always a root interpreter in the slot 0 of private->interps, - * so we always need to run this cycle at least once + * so we always need to run this cycle at least once */ server = module_globals->server; @@ -201,12 +201,12 @@ void Rivet_ProcessorCleanup (rivet_thread_private* private) Rivet_ReleaseRivetChannel(private->ext->interps[i]->interp,private->ext->interps[i]->channel); } - if ((i > 0) && module_globals->separate_channels) + if ((i > 0) && module_globals->separate_channels) Rivet_ReleaseRivetChannel(private->ext->interps[i]->interp,private->ext->interps[i]->channel); Rivet_ReleaseRunningScripts(private->ext->interps[i]->scripts); i++; - } + } } diff --git a/src/mod_rivet_ng/worker_prefork_common.h b/src/mod_rivet_ng/worker_prefork_common.h index 6b5e21e..5bd94cb 100644 --- a/src/mod_rivet_ng/worker_prefork_common.h +++ b/src/mod_rivet_ng/worker_prefork_common.h @@ -22,7 +22,7 @@ #ifndef __worker_prefork_common_h__ #define __worker_prefork_common_h__ -/* Thread specific data common to the worker and prefork bridges +/* Thread specific data common to the worker and prefork bridges * Actually the prefork bridge won't use the keep_going flag, but * they share the same interpreters array */ diff --git a/src/parser/parserPkgInit.c b/src/parser/parserPkgInit.c index 205c617..1b2f554 100644 --- a/src/parser/parserPkgInit.c +++ b/src/parser/parserPkgInit.c @@ -1,5 +1,5 @@ /* - * parserPkgInit.c - This code provides a wrapper around rivetParser.c, + * parserPkgInit.c - This code provides a wrapper around rivetParser.c, * in order to expose it to Tcl scripts not running in Rivet. */ @@ -141,7 +141,7 @@ Rivetparser_Init( Tcl_Interp *interp ) #else if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) #endif - { + { return TCL_ERROR; } @@ -165,9 +165,9 @@ Rivetparser_SafeInit( Tcl_Interp *interp ) */ #ifdef USE_TCL_STUBS - if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) #else - if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) + if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) #endif { return TCL_ERROR; diff --git a/src/parser/rivetParser.c b/src/parser/rivetParser.c index fe978a3..e05941b 100644 --- a/src/parser/rivetParser.c +++ b/src/parser/rivetParser.c @@ -87,9 +87,9 @@ Rivet_GetTclFile(char *filename, Tcl_Obj *outbuf, Tcl_Interp *interp) #if RIVET_CORE == mod_rivet_ng /* *----------------------------------------------------------------------------- - * Rivet_GetRivetFileNG -- + * Rivet_GetRivetFileNG -- * - * The mod_rivet_ng core doesn't assume the parsed script to be + * The mod_rivet_ng core doesn't assume the parsed script to be * enclosed in the ::request namespace. The whole ::request lifecycle is * devolved to the Rivet::request_handling procedure * @@ -104,7 +104,7 @@ Rivet_GetRivetFile(char *filename, Tcl_Obj *outbuf, Tcl_Interp *interp) Tcl_Channel rivetfile; /* - * we call Tcl to read this file but the caveat exposed in + * we call Tcl to read this file but the caveat exposed in * in Rivet_GetRivetFile still holds true (TODO) */ diff --git a/src/request/apache_multipart_buffer.c b/src/request/apache_multipart_buffer.c index 484b8f3..28a78ed 100644 --- a/src/request/apache_multipart_buffer.c +++ b/src/request/apache_multipart_buffer.c @@ -82,7 +82,7 @@ int fill_buffer(multipart_buffer *self) /* read the required number of bytes */ if(bytes_to_read > 0) { char *buf = self->buffer + self->bytes_in_buffer; - + actual_read = ap_get_client_block(self->r, buf, bytes_to_read); /* update the buffer length */ @@ -219,8 +219,8 @@ apr_table_t *multipart_buffer_headers(multipart_buffer *self) if(value) { *value = 0; - do { - value++; + do { + value++; } while (apr_isspace(*value)); #ifdef DEBUG diff --git a/src/request/apache_multipart_buffer.h b/src/request/apache_multipart_buffer.h index b899a46..dfe722c 100644 --- a/src/request/apache_multipart_buffer.h +++ b/src/request/apache_multipart_buffer.h @@ -26,7 +26,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif typedef struct _multipart_buffer { /* request info */ @@ -48,7 +48,7 @@ typedef struct _multipart_buffer { multipart_buffer* multipart_buffer_new(char* boundary,apr_off_t length,request_rec* r); ///*table*/apr_table_t *multipart_buffer_headers(multipart_buffer *self); size_t multipart_buffer_read(multipart_buffer* self,char* buf,size_t bytes); -char* multipart_buffer_read_body(multipart_buffer *self); +char* multipart_buffer_read_body(multipart_buffer *self); apr_table_t* multipart_buffer_headers(multipart_buffer *self); int multipart_buffer_eof(multipart_buffer *self); diff --git a/src/request/apache_request.c b/src/request/apache_request.c index b370273..79c3f20 100644 --- a/src/request/apache_request.c +++ b/src/request/apache_request.c @@ -403,7 +403,7 @@ int ApacheRequest___parse(ApacheRequest *req) req->nargs = ((apr_array_header_t *)req->parms)->nelts; } - if ((r->method_number == M_POST) && ct && strncaseEQ(ct, MULTIPART_ENCTYPE, MULTIPART_ENCTYPE_LENGTH)) + if ((r->method_number == M_POST) && ct && strncaseEQ(ct, MULTIPART_ENCTYPE, MULTIPART_ENCTYPE_LENGTH)) { // //ap_log_rerror(REQ_INFO, "content-type: `%s'", ct); @@ -430,7 +430,7 @@ int ApacheRequest_parse_urlencoded(ApacheRequest *req) /* const char *type; type = apr_table_get(r->headers_in, "Content-Type"); - + if (!strncaseEQ(type, DEFAULT_ENCTYPE, DEFAULT_ENCTYPE_LENGTH) && !strncaseEQ(type, TEXT_XML_ENCTYPE, TEXT_XML_ENCTYPE_LENGTH)) { return DECLINED; @@ -476,14 +476,14 @@ apr_file_t *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload) request_rec *r = req->r; apr_file_t *fp = NULL; char *name = NULL; - char *file = NULL ; + char *file = NULL ; const char *tempdir; apr_status_t rv; tempdir = req->temp_dir; /* file = (char *)apr_palloc(r->pool,sizeof(apr_time_t)); */ file = apr_psprintf(r->pool,"%u.XXXXXX", (unsigned int)r->request_time); - rv = apr_temp_dir_get(&tempdir,r->pool); + rv = apr_temp_dir_get(&tempdir,r->pool); if (rv != APR_SUCCESS) { ap_log_perror(APLOG_MARK, APLOG_ERR, rv, r->pool, "No temp dir!"); return NULL; @@ -494,7 +494,7 @@ apr_file_t *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload) ap_log_perror(APLOG_MARK, APLOG_ERR, rv, r->pool, "File path error!"); return NULL; } - + rv = apr_file_mktemp(&fp,name,0,r->pool); if (rv != APR_SUCCESS) { char* errorBuffer = (char*) apr_palloc(r->pool,256); @@ -623,10 +623,10 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct) /* mozilla empty-file (missing CRLF) hack */ fill_buffer(mbuff); - if( strEQN(mbuff->buf_begin, mbuff->boundary, + if( strEQN(mbuff->buf_begin, mbuff->boundary, strlen(mbuff->boundary)) ) { r->remaining -= 2; - continue; + continue; } while ((blen = multipart_buffer_read(mbuff, buff, sizeof(buff)))) { @@ -634,7 +634,7 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct) status = apr_file_write(upload->fp,buff,&bytes_to_write); if (status != 0) { - apr_strerror(status,error,1024); + apr_strerror(status,error,1024); return HTTP_INTERNAL_SERVER_ERROR; } upload->size += blen; diff --git a/src/request/apache_request.h b/src/request/apache_request.h index 22b8058..300da12 100644 --- a/src/request/apache_request.h +++ b/src/request/apache_request.h @@ -61,7 +61,7 @@ extern Sfio_t* _stdopen _ARG_((int, const char*)); /*1999*/ #ifdef __cplusplus extern "C" { -#endif +#endif ApacheRequest* ApacheRequest_new(apr_pool_t *); ApacheRequest* ApacheRequest_init(ApacheRequest* req, request_rec *r); @@ -76,7 +76,7 @@ apr_array_header_t *ApacheRequest_params(ApacheRequest *req, const char *key); char *ApacheRequest_params_as_string(ApacheRequest *req, const char *key); int ApacheRequest___parse(ApacheRequest *req); #define ApacheRequest_parse(req) \ - ((req)->status = (req)->parsed ? (req)->status : ApacheRequest___parse(req)) + ((req)->status = (req)->parsed ? (req)->status : ApacheRequest___parse(req)) apr_table_t *ApacheRequest_query_params(ApacheRequest *req, apr_pool_t *p); apr_table_t *ApacheRequest_post_params(ApacheRequest *req, apr_pool_t *p); apr_table_t *ApacheRequest_query_params(ApacheRequest *req, apr_pool_t *p); diff --git a/src/rivet.h b/src/rivet.h index f3213b1..d987379 100644 --- a/src/rivet.h +++ b/src/rivet.h @@ -45,7 +45,7 @@ typedef int rivet_req_ctype; #define RIVET_PRIVATE_DATA(thread_key,private_p) \ ap_assert (apr_threadkey_private_get ((void **)&private_p,thread_key) == APR_SUCCESS); - + #define RIVET_PRIVATE_DATA_NOT_NULL(thread_key,private_p) \ RIVET_PRIVATE_DATA(thread_key,private_p) \ ap_assert (private_p != NULL); @@ -67,12 +67,12 @@ Tcl_CreateObjCommand (interp, /* Tcl interpreter */\ (Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */) /* RIVET_OBJ_CMD creates a command in the RIVET_NS namespace. Commands - * are exported from the RIVET_NS (::rivet) namespace in the init.tcl + * are exported from the RIVET_NS (::rivet) namespace in the init.tcl * script accordingly to configuration switches passed to ./configure * (see configure.ac) */ - /* We now pass the thread private data to the + /* We now pass the thread private data to the * Tcl command's ClientData */ @@ -81,16 +81,16 @@ Tcl_CreateObjCommand( interp, /* Tcl interpreter */\ RIVET_NS "::" name, /* Function name in Tcl */\ func, /* C function name */\ private_p, /* Client Data */\ - (Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */); + (Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */); #define RIVET_EXPORT_CMD(interp,ns,cmdname) Tcl_Export(interp,ns,cmdname,0); -/* +/* * Pointer in r is checked and in case Rivet_NoRequestRec is * called returning TCL_ERROR. This macro is used (and often * is the first code like) in commands that must ascertain - * the request_rec object pointer in globals is valid + * the request_rec object pointer in globals is valid * (when a request processing ends it's set to NULL) */ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@tcl.apache.org For additional commands, e-mail: commits-h...@tcl.apache.org