User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:xatmi:tpsrvsetctxdata.3

tpsrvsetctxdata

Name

tpsrvsetctxdata — Set server context data for multi threaded server

Synopsis

#include <atmi.h>

int tpsrvsetctxdata (char *data, long flags);

Link with -latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm

DESCRIPTION

Restore context data from previously saved (tpsrvgetctxdata()) context data. The data field is value returned by tpsrvgetctxdata(). This function is needed for multi threaded server, in order to restore tpcall() data in worker thread. If global transaction was running in main thread for which tpsrvgetctxdata() was called, then tpsrvsetctxdata() will resume the global transaction in current thread.

In case when restoring context in other server process service, the auto-buffer marking (buffer allocated by incoming message service dispatcher and marked as auto-buffer) is lost. Thus when doing tpreturn(3) or tpforward(3) with other buffer, than original service incoming call buffer, the original call buffer (initial auto-buffer) will leak. By contrast of normal service work, where tpsrvsetctxdata() is not used, the auto-buffer will be freed by system, even doing return with other XATMI buffer.

Thus to avoid leaking, either tpreturn() or tpforward() shall be done with original call buffer, or if not possible, then after doing tpsrvsetctxdata(), original call buffer shall be freed by tpfree(3).

This function is available only for XATMI servers.

Valid flags

TPNOAUTBUF Do not restore auto buffer when restoring the server context. This can be suitable in case if buffer is already made free by initial service thread and the target server/service does not know anything about given pointer. E.g. the context is copied to different process. If context is copied to other process without using this flag, then segmentation fault is possible at tpreturn() or tpforward().

RETURN VALUE

On success, tpsrvsetctxdata() return pointer to context data block; on error, NULL is returned, with tperrno set to indicate the error.

ERRORS

Note that tpstrerror() returns generic error message plus custom message with debug info from last function call.

TPEINVAL data is NULL.

TPEPROTO Global transaction is already started.

TPESYSTEM System failure occurred during serving. See logs i.e. user log, or debugs for more info. Could be the case if XA sub-system is not open by tpopen().

TPEOS System failure occurred during serving. See logs i.e. user log, or debugs for more info.

EXAMPLE

See atmitest/test017_srvthread/atmisv17.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd