You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/09/29 21:11:29 UTC
[tcl-rivet] branch master updated: Reforming and completing
thread_id
This is an automated email from the ASF dual-hosted git repository.
mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
The following commit(s) were added to refs/heads/master by this push:
new b393958 Reforming and completing thread_id
b393958 is described below
commit b3939588b50e4a97e0b2812014d11618f1bf36d1
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sun Sep 29 23:11:12 2019 +0200
Reforming and completing thread_id
---
ChangeLog | 6 +++++
doc/xml/commands.xml | 12 +++++-----
src/mod_rivet_ng/rivetCore.c | 52 ++++++++++++++++++++++++++++++++++----------
3 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 67e1cc4..c35fb7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-29 Massimo Manghi <mx...@apache.org>
+ * doc/xml/commands.xml: Completed manual page for command ::rivet::thread_id
+ * src/mod_rivet_ng/rivetCore.c: Rivet_GetThreadId rewritten. Now the
+ command accepts an optional argument to select decimal or hexadecimal (default)
+ output
+
2019-08-05 Massimo Manghi <mx...@apache.org>
* doc/xml/directives.xml: Documenting SingleThreadExit directive
diff --git a/doc/xml/commands.xml b/doc/xml/commands.xml
index c423952..ddbf976 100644
--- a/doc/xml/commands.xml
+++ b/doc/xml/commands.xml
@@ -1563,16 +1563,18 @@ bab</programlisting>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::thread_id</command>
+ <arg>-decimal | -hex</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
- <command>::rivet::try</command> wraps the core language
- command and simply traps exceptions that might have raised
- by <command>::rivet::abort_page</command> and
- <command>::rivet::exit</command> to throw them again and
- thus causing <command>AbortScript</command> to be executed.
+ <command>::rivet::threadid</command> returns is either hexadecimal
+ (default) or decimal representation the current thread id. This command
+ is useful because allows for precise identification of an execution thread
+ when Apache runs a threaded MPM. Calling the command with <arg>-decimal</arg>
+ prints the thread id in a form that makes it comparable with the <command>tid</command>
+ information printed in the error log.
</para>
</refsect1>
</refentry>
diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c
index 0fa7c2c..57e6aa6 100644
--- a/src/mod_rivet_ng/rivetCore.c
+++ b/src/mod_rivet_ng/rivetCore.c
@@ -1562,7 +1562,7 @@ TCL_CMD_HEADER( Rivet_InspectCmd )
char* cmd_arg;
Tcl_IncrRefCount(par_name);
- cmd_arg = Tcl_GetStringFromObj(par_name,NULL);
+ cmd_arg = Tcl_GetStringFromObj(par_name,NULL);
if (STRNEQU(cmd_arg,"script"))
{
@@ -1956,24 +1956,52 @@ TCL_CMD_HEADER( Rivet_UrlScript )
TCL_CMD_HEADER( Rivet_GetThreadId )
{
- rivet_thread_private* private;
char buff[SMALL_BUFFER_SIZE];
apr_os_thread_t threadid;
Tcl_Obj* result_obj;
- rivet_thread_interp* interp_obj;
-
- threadid = apr_os_thread_current();
+ char* format_hex = "0x%8.8lx";
+ char* format_dec = "%ld";
+ char* output_format = format_hex;
+ int wrong_args = false;
+ //rivet_thread_interp* interp_obj;
- THREAD_PRIVATE_DATA(private)
+ // interp_obj = RIVET_PEEK_INTERP(private,private->running_conf);
+ if (objc == 2)
+ {
+ Tcl_Obj* argobj = objv[1];
+ char* cmd_arg;
- interp_obj = RIVET_PEEK_INTERP(private,private->running_conf);
+ Tcl_IncrRefCount(argobj);
+ cmd_arg = Tcl_GetStringFromObj(argobj,NULL);
+ if (STRNEQU(cmd_arg,"-hex"))
+ {
+ output_format = format_hex;
+ }
+ else if (STRNEQU(cmd_arg,"-decimal"))
+ {
+ output_format = format_dec;
+ }
+ else
+ {
+ wrong_args = true;
+ }
+ Tcl_DecrRefCount(argobj);
+ }
- threadid = apr_os_thread_current();
- snprintf(buff,SMALL_BUFFER_SIZE,"0x%8.8lx",threadid);
- result_obj = Tcl_NewStringObj(buff,strlen(buff));
+ if (wrong_args)
+ {
+ Tcl_WrongNumArgs(interp,1,objv,"-decimal | -hex" );
+ return TCL_ERROR;
+ }
+ else
+ {
+ threadid = apr_os_thread_current();
+ snprintf(buff,SMALL_BUFFER_SIZE,output_format,threadid);
+ result_obj = Tcl_NewStringObj(buff,strlen(buff));
- Tcl_SetObjResult(interp_obj->interp,result_obj);
- return TCL_OK;
+ Tcl_SetObjResult(interp,result_obj);
+ return TCL_OK;
+ }
}
/*
*-----------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org