xref: /illumos-gate/usr/src/cmd/sendmail/db/include/xa.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 1998
5  *	Sleepycat Software.  All rights reserved.
6  *
7  *	@(#)xa.h	10.1 (Sleepycat) 6/22/98
8  */
9 
10 #pragma ident	"%Z%%M%	%I%	%E% SMI"
11 
12 /*
13  * Start of xa.h header
14  *
15  * Define a symbol to prevent multiple inclusions of this header file
16  */
17 #ifndef	XA_H
18 #define	XA_H
19 
20 /*
21  * Transaction branch identification: XID and NULLXID:
22  */
23 #define	XIDDATASIZE	128		/* size in bytes */
24 #define	MAXGTRIDSIZE	 64		/* maximum size in bytes of gtrid */
25 #define	MAXBQUALSIZE	 64		/* maximum size in bytes of bqual */
26 
27 struct xid_t {
28 	long formatID;			/* format identifier */
29 	long gtrid_length;		/* value from 1 through 64 */
30 	long bqual_length;		/* value from 1 through 64 */
31 	char data[XIDDATASIZE];
32 };
33 typedef	struct xid_t XID;
34 /*
35  * A value of -1 in formatID means that the XID is null.
36  */
37 
38 /*
39  * Declarations of routines by which RMs call TMs:
40  */
41 extern int ax_reg __P((int, XID *, long));
42 extern int ax_unreg __P((int, long));
43 
44 /*
45  * XA Switch Data Structure
46  */
47 #define	RMNAMESZ	32		/* length of resource manager name, */
48 					/* including the null terminator */
49 #define	MAXINFOSIZE	256		/* maximum size in bytes of xa_info */
50 					/* strings, including the null
51 					terminator */
52 struct xa_switch_t {
53 	char name[RMNAMESZ];		/* name of resource manager */
54 	long flags;			/* resource manager specific options */
55 	long version;			/* must be 0 */
56 	int (*xa_open_entry)		/* xa_open function pointer */
57 	    __P((char *, int, long));
58 	int (*xa_close_entry)		/* xa_close function pointer */
59 	    __P((char *, int, long));
60 	int (*xa_start_entry)		/* xa_start function pointer */
61 	    __P((XID *, int, long));
62 	int (*xa_end_entry)		/* xa_end function pointer */
63 	    __P((XID *, int, long));
64 	int (*xa_rollback_entry)	/* xa_rollback function pointer */
65 	    __P((XID *, int, long));
66 	int (*xa_prepare_entry)		/* xa_prepare function pointer */
67 	    __P((XID *, int, long));
68 	int (*xa_commit_entry)		/* xa_commit function pointer */
69 	    __P((XID *, int, long));
70 	int (*xa_recover_entry)		/* xa_recover function pointer */
71 	    __P((XID *, long, int, long));
72 	int (*xa_forget_entry)		/* xa_forget function pointer */
73 	    __P((XID *, int, long));
74 	int (*xa_complete_entry)	/* xa_complete function pointer */
75 	    __P((int *, int *, int, long));
76 };
77 
78 /*
79  * Flag definitions for the RM switch
80  */
81 #define	TMNOFLAGS	0x00000000L	/* no resource manager features
82 					selected */
83 #define	TMREGISTER	0x00000001L	/* resource manager dynamically
84 					registers */
85 #define	TMNOMIGRATE	0x00000002L	/* resource manager does not support
86 					association migration */
87 #define	TMUSEASYNC	0x00000004L	/* resource manager supports
88 					asynchronous operations */
89 /*
90  * Flag definitions for xa_ and ax_ routines
91  */
92 /* use TMNOFLAGGS, defined above, when not specifying other flags */
93 #define	TMASYNC		0x80000000L	/* perform routine asynchronously */
94 #define	TMONEPHASE	0x40000000L	/* caller is using one-phase commit
95 					optimisation */
96 #define	TMFAIL		0x20000000L	/* dissociates caller and marks
97 					transaction branch rollback-only */
98 #define	TMNOWAIT	0x10000000L	/* return if blocking condition
99 					exists */
100 #define	TMRESUME	0x08000000L	/* caller is resuming association with
101 					suspended transaction branch */
102 #define	TMSUCCESS	0x04000000L	/* dissociate caller from transaction
103 					branch */
104 #define	TMSUSPEND	0x02000000L	/* caller is suspending, not ending,
105 					association */
106 #define	TMSTARTRSCAN	0x01000000L	/* start a recovery scan */
107 #define	TMENDRSCAN	0x00800000L	/* end a recovery scan */
108 #define	TMMULTIPLE	0x00400000L	/* wait for any asynchronous
109 					operation */
110 #define	TMJOIN		0x00200000L	/* caller is joining existing
111 					transaction branch */
112 #define	TMMIGRATE	0x00100000L	/* caller intends to perform
113 					migration */
114 
115 /*
116  * ax_() return codes (transaction manager reports to resource manager)
117  */
118 #define	TM_JOIN		2		/* caller is joining existing
119 					transaction branch */
120 #define	TM_RESUME	1		/* caller is resuming association with
121 					suspended transaction branch */
122 #define	TM_OK		0		/* normal execution */
123 #define	TMER_TMERR	-1		/* an error occurred in the transaction
124 					manager */
125 #define	TMER_INVAL	-2		/* invalid arguments were given */
126 #define	TMER_PROTO	-3		/* routine invoked in an improper
127 					context */
128 
129 /*
130  * xa_() return codes (resource manager reports to transaction manager)
131  */
132 #define	XA_RBBASE	100		/* The inclusive lower bound of the
133 					rollback codes */
134 #define	XA_RBROLLBACK	XA_RBBASE	/* The rollback was caused by an
135 					unspecified reason */
136 #define	XA_RBCOMMFAIL	XA_RBBASE+1	/* The rollback was caused by a
137 					communication failure */
138 #define	XA_RBDEADLOCK	XA_RBBASE+2	/* A deadlock was detected */
139 #define	XA_RBINTEGRITY	XA_RBBASE+3	/* A condition that violates the
140 					integrity of the resources was
141 					detected */
142 #define	XA_RBOTHER	XA_RBBASE+4	/* The resource manager rolled back the
143 					transaction branch for a reason not
144 					on this list */
145 #define	XA_RBPROTO	XA_RBBASE+5	/* A protocol error occurred in the
146 					resource manager */
147 #define	XA_RBTIMEOUT	XA_RBBASE+6	/* A transaction branch took too long */
148 #define	XA_RBTRANSIENT	XA_RBBASE+7	/* May retry the transaction branch */
149 #define	XA_RBEND	XA_RBTRANSIENT	/* The inclusive upper bound of the
150 					rollback codes */
151 #define	XA_NOMIGRATE	9		/* resumption must occur where
152 					suspension occurred */
153 #define	XA_HEURHAZ	8		/* the transaction branch may have
154 					been heuristically completed */
155 #define	XA_HEURCOM	7		/* the transaction branch has been
156 					heuristically committed */
157 #define	XA_HEURRB	6		/* the transaction branch has been
158 					heuristically rolled back */
159 #define	XA_HEURMIX	5		/* the transaction branch has been
160 					heuristically committed and rolled
161 					back */
162 #define	XA_RETRY	4		/* routine returned with no effect and
163 					may be re-issued */
164 #define	XA_RDONLY	3		/* the transaction branch was read-only
165 					and has been committed */
166 #define	XA_OK		0		/* normal execution */
167 #define	XAER_ASYNC	-2		/* asynchronous operation already
168 					outstanding */
169 #define	XAER_RMERR	-3		/* a resource manager error occurred in
170 					 the transaction branch */
171 #define	XAER_NOTA	-4		/* the XID is not valid */
172 #define	XAER_INVAL	-5		/* invalid arguments were given */
173 #define	XAER_PROTO	-6		/* routine invoked in an improper
174 					context */
175 #define	XAER_RMFAIL	-7		/* resource manager unavailable */
176 #define	XAER_DUPID	-8		/* the XID already exists */
177 #define	XAER_OUTSIDE	-9		/* resource manager doing work outside
178 					transaction */
179 #endif /* ifndef XA_H */
180 /*
181  * End of xa.h header
182  */
183