Back to home page

Enduro/X

 
 

    


0001 TPSRVSETCTXDATA(3)
0002 ==================
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 tpsrvsetctxdata - Set server context data for multi threaded server
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014 
0015 int tpsrvsetctxdata (char *'data', long 'flags');
0016 
0017 Link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0018 
0019 DESCRIPTION
0020 -----------
0021 Restore context data from previously saved (*tpsrvgetctxdata()*) context data. 
0022 The 'data' field is value returned by *tpsrvgetctxdata()*. This function is 
0023 needed for multi threaded server, in order to restore tpcall() data in worker thread. 
0024 If global transaction was running in main thread for which *tpsrvgetctxdata()* 
0025 was called, then *tpsrvsetctxdata()* will resume the global transaction in current thread.
0026 
0027 In case when restoring context in other server process service, the
0028 auto-buffer marking (buffer allocated by incoming message service dispatcher and
0029 marked as auto-buffer) is lost. Thus when doing *tpreturn(3)* 
0030 or *tpforward(3)* with other buffer, than original service 
0031 incoming call buffer, the original call buffer (initial auto-buffer) will leak. By
0032 contrast of normal service work, where *tpsrvsetctxdata()* is not used, the 
0033 auto-buffer will be freed by system, even doing return with other XATMI buffer.
0034 
0035 Thus to avoid leaking, either *tpreturn()* or *tpforward()* shall be done with original
0036 call buffer, or if not possible, then after doing *tpsrvsetctxdata()*, original
0037 call buffer shall be freed by *tpfree(3)*.
0038 
0039 This function is available only for XATMI servers.
0040 
0041 *Valid flags*
0042 
0043 *TPNOAUTBUF* Do not restore auto buffer when restoring the server context. 
0044 This can be suitable in case if buffer is already made free by initial service thread
0045 and the target server/service does not know anything about given pointer. E.g.
0046 the context is copied to different process. If context is copied to other process
0047 without using this flag, then segmentation fault is possible at *tpreturn()*
0048 or *tpforward()*.
0049 
0050 RETURN VALUE
0051 ------------
0052 On success, *tpsrvsetctxdata()* return 0; on error, -1 is returned, with *tperrno* set to indicate the error.
0053 
0054 ERRORS
0055 ------
0056 Note that *tpstrerror()* returns generic error message plus custom message with 
0057 debug info from last function call.
0058 
0059 *TPEINVAL* 'data' is NULL.
0060 
0061 *TPEPROTO* Global transaction is already started.
0062 
0063 *TPESYSTEM* System failure occurred during serving. See logs i.e. user log, or 
0064 debugs for more info. Could be the case if XA sub-system is not open by *tpopen()*.
0065 
0066 *TPEOS* System failure occurred during serving. See logs i.e. user log, or debugs for more info.
0067 
0068 EXAMPLE
0069 -------
0070 See *atmitest/test017_srvthread/atmisv17.c* for sample code.
0071 
0072 BUGS
0073 ----
0074 Report bugs to support@mavimax.com
0075 
0076 SEE ALSO
0077 --------
0078 *tpsrvgetctxdata(3)* *tpcontinue(3)* *tpinit(3)* *tpreturn(3)* *tpforward(3)*
0079 *tpfree(3)*
0080 
0081 COPYING
0082 -------
0083 (C) Mavimax, Ltd
0084