]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/test/external-agent.h
tdb2: unify tdb1_store into tdb_store
[ccan] / ccan / tdb2 / test / external-agent.h
1 #ifndef TDB2_TEST_EXTERNAL_AGENT_H
2 #define TDB2_TEST_EXTERNAL_AGENT_H
3
4 /* For locking tests, we need a different process to try things at
5  * various times. */
6 enum operation {
7         OPEN,
8         OPEN_WITH_HOOK,
9         FETCH,
10         STORE,
11         TRANSACTION_START,
12         TRANSACTION_COMMIT,
13         NEEDS_RECOVERY,
14         CHECK,
15         SEND_SIGNAL,
16         CLOSE,
17 };
18
19 /* Do this before doing any tdb stuff.  Return handle, or -1. */
20 struct agent *prepare_external_agent(void);
21
22 enum agent_return {
23         SUCCESS,
24         WOULD_HAVE_BLOCKED,
25         AGENT_DIED,
26         FAILED, /* For fetch, or NEEDS_RECOVERY */
27         OTHER_FAILURE,
28 };
29
30 /* Ask the external agent to try to do an operation. 
31  * name == tdb name for OPEN/OPEN_WITH_CLEAR_IF_FIRST,
32  * record name for FETCH/STORE (store stores name as data too)
33  */
34 enum agent_return external_agent_operation(struct agent *handle,
35                                            enum operation op,
36                                            const char *name);
37
38 /* Mapping enum -> string. */
39 const char *agent_return_name(enum agent_return ret);
40 const char *operation_name(enum operation op);
41
42 void free_external_agent(struct agent *agent);
43 #endif /* TDB2_TEST_EXTERNAL_AGENT_H */