stAbortThis(3) simple transaction handling

Other Alias

stThisTransaction

SYNOPSIS

#include <config.h>
#include <sttk.h>

voidstAbortThis (int domsg);

struct stTransactionstThisTransaction;

DESCRIPTION

stAbortThis is part of a simple transaction mechanism on the basis of setjmp(3) and longjmp(3). A transacion is started by setting a return point calling setjmp(3) and may be aborted by calling stAbortThis. This outputs a short abort message, cleans up the temporary files (stRmRegisteredFiles(3)) and performs a longjmp(3) operation, returning to the transaction start point.

The structure variable stThisTransaction carries information about the current transaction. It has the following fields:

struct stTransaction {
  char tr_fname[MAXPATHLEN+1];
  int tr_done;
  int tr_seqno;
  int tr_rc;
  jmp_buf tr_env;
};

When setting the transaction return point by calling setjmp(3) the tr_env field must be used as argument to setjmp. The name of the concerned file should be stored in tr_fname field and the tr_done flag should be cleared. tr_seqno is the serial number of the current transaction and must be increased at the beginning of each new transaction. The tr_rc return code can be set to an appropriate return code when something went wrong and the transaction was aborted. When not set by the application, tr_rc will be set nun null by stAbortThis on abortion of the transaction. On successful completion, tr_done should be set TRUE.