In a message dated 2/15/2003 5:22:48 PM Eastern Standard Time, [EMAIL PROTECTED] writes:

Could someone please explain the different uses of the "ClientData
arg" parameter to the Nsv C functions in AOLserver 3.x vs. 4.0?




Hi,

In AOLserver 3.x, the ClientData was normally ignored or used to trigger slightly different behavior for similar commands.  In this case, AOLserver commands which needed per-interp state would use thread specific data assuming a single interp for each thread.  Virtual server specific data was simply global data because virtual servers were removed in 3.x.

In AOLserver 4.x I "rediscovered" the ClientData and used it extensively in a consistant manner.  All commands are created with a pointer to the new NsInterp structure which packages up all the per-interp state (e.g., ADP buffers) and a pointer to the cooresponding NsServer structure.  This restored virtual server support without a performance penalty, enabled multiple interps per thread, and generally made the code more rationale.

It turns out the ClientData can be NULL for interps created without a virtual server such as the startup/config interp and interps created after libnsd.so is loaded into tclsh (which is a weird new possibility).  A few commands deal with that directly (e.g., ns_info), others ignore ClientData anyway, and others simply don't exist in such interps.  The command create code in nsd/tclcmds.c takes care of this.

One more trick to point out if you explore the code:  The NsInterp structure is actually managed (although rarely accessed through) the Tcl_Get/SetAssocDatas APIs.  This allows proper cleanup of the structure if you delete it directly via Tcl_DeleteInterp.  Check nsd/tclinit.c to see how this is done.
      
-Jim

Reply via email to