Back to home page

Enduro/X

 
 

    


0001 TPGETCTXT(3)
0002 ============
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 tpgetctxt - Get context data (thread local storage data)
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014 
0015 int tpgetctxt(TPCONTEXT_T *'context', long 'flags');
0016 
0017 Link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0018 
0019 DESCRIPTION
0020 -----------
0021 Function is used to get thread local storage data (TLS) associated with current 
0022 thread. The current thread after calling this function becomes disassociated 
0023 from any TLS and is running in NULL context. How every, any ATMI call will make
0024 to initialize new client TLS. Due to nature of the function, that it is 
0025 suspending full ATMI TLS setup, it should not be used from ATMI server's main
0026 thread (service dispatcher), how ever it is safe to use it in ATMI server's
0027 client threads. The 'context' variable points to space where to save the current
0028 thread's TLS data.  'flags' shall be set to 0. Any global XA transaction
0029 currently associated with thread becomes suspended, and it's suspend data is 
0030 saved in returned context data.
0031 
0032 If the context data is not restored by *tpsetctxt(3)* then you have to make
0033 the data free by *tpfreectxt(3)* call, otherwise memory will be leaked.
0034 
0035 To pass the request from server main thread to worker thread,
0036 use *tpsrvgetctxdata(3)* and *tpsrvsetctxdata(3)*.
0037 
0038 This function uses underlaying thread local storage infrastructure which is
0039 provided separately for each of the major Enduro/X libraries - libnstd 
0040 (Standard library), libufb (UBF buffer library) and libatmi (ATMI library). 
0041 If operations at library levels are required, then following functions can be used:
0042 
0043 1. ndrx_nstd_tls_new(), ndrx_ubf_tls_new(), ndrx_atmi_tls_new() - 
0044 allocate TLS data for library.
0045 
0046 2. ndrx_nstd_tls_get(), ndrx_ubf_tls_get(), ndrx_atmi_tls_get() - get the
0047 TLS data for library (currently associated with thread).
0048 
0049 3. ndrx_nstd_tls_set(), ndrx_ubf_tls_set(), ndrx_atmi_tls_set() - set the thread
0050 local data from saved pointer.
0051 
0052 4. ndrx_nstd_tls_free(), ndrx_ubf_tls_free(), ndrx_atmi_tls_free() - free the
0053 thread local data.
0054 
0055 
0056 RETURN VALUE
0057 ------------
0058 On success, *tpgetctxt()* return *TPMULTICONTEXTS* if context/TLS data was set,
0059 *TPNULLCONTEXT* if running in NULL context (no TLS initialized - there was no 
0060 ATMI calls); on error, -1 is returned, with *tperrno* set to indicate the error.
0061 
0062 ERRORS
0063 ------
0064 Note that *tpstrerror()* returns generic error message plus custom message 
0065 with debug info from last function call. Error data (tperrno) is valid only 
0066 if return was -1. In case if process was running in *TPNULLCONTEXT*, new 
0067 client context will be made to store the error code.
0068 
0069 *TPEINVAL* 'context' parameter was NULL or flags was not 0.
0070 
0071 EXAMPLE
0072 -------
0073 See *atmitest/test016_contextsw/atmiclt16.c* for sample code.
0074 
0075 BUGS
0076 ----
0077 Report bugs to support@mavimax.com
0078 
0079 SEE ALSO
0080 --------
0081 *tpsetctxt(3)* *tpfreectxt(3)* *tpsrvsetctxdata(3)* *tpsrvgetctxdata(3)* 
0082 *tpcontinue(3)* *tpinit(3)*
0083 
0084 COPYING
0085 -------
0086 (C) Mavimax, Ltd
0087