external-agent.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef NTDB_TEST_EXTERNAL_AGENT_H
  2. #define NTDB_TEST_EXTERNAL_AGENT_H
  3. /* For locking tests, we need a different process to try things at
  4. * various times. */
  5. enum operation {
  6. OPEN,
  7. OPEN_WITH_HOOK,
  8. FETCH,
  9. STORE,
  10. TRANSACTION_START,
  11. TRANSACTION_COMMIT,
  12. NEEDS_RECOVERY,
  13. CHECK,
  14. SEND_SIGNAL,
  15. CLOSE,
  16. };
  17. /* Do this before doing any ntdb stuff. Return handle, or -1. */
  18. struct agent *prepare_external_agent(void);
  19. enum agent_return {
  20. SUCCESS,
  21. WOULD_HAVE_BLOCKED,
  22. AGENT_DIED,
  23. FAILED, /* For fetch, or NEEDS_RECOVERY */
  24. OTHER_FAILURE,
  25. };
  26. /* Ask the external agent to try to do an operation.
  27. * name == ntdb name for OPEN/OPEN_WITH_CLEAR_IF_FIRST,
  28. * <key>=<data> for FETCH/STORE.
  29. */
  30. enum agent_return external_agent_operation(struct agent *handle,
  31. enum operation op,
  32. const char *name);
  33. /* Hook into free() on ntdb_data in external agent. */
  34. extern void (*external_agent_free)(void *);
  35. /* Mapping enum -> string. */
  36. const char *agent_return_name(enum agent_return ret);
  37. const char *operation_name(enum operation op);
  38. void free_external_agent(struct agent *agent);
  39. /* Internal use: */
  40. struct ntdb_context;
  41. enum agent_return external_agent_needs_rec(struct ntdb_context *ntdb);
  42. #endif /* NTDB_TEST_EXTERNAL_AGENT_H */