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