diff options
author | Keith Bostic <keith@wiredtiger.com> | 2016-02-23 09:52:18 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2016-02-23 09:52:18 -0500 |
commit | b6a1357f1a3ba992166779ab944aa1774d15243d (patch) | |
tree | 0a17e8e8d22aae228dabe36b6b06900721260f0c /examples | |
parent | f90fb74abfd080de37ea92e6091d356d37cf3d25 (diff) | |
download | mongo-b6a1357f1a3ba992166779ab944aa1774d15243d.tar.gz |
WT-2107: Add example code including an event handler
Add WIREDTIGER_HOME handling so "make check" works, remove unused variable.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/ex_event_handler.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/c/ex_event_handler.c b/examples/c/ex_event_handler.c index fae61092687..76af3e324f4 100644 --- a/examples/c/ex_event_handler.c +++ b/examples/c/ex_event_handler.c @@ -30,11 +30,11 @@ * */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <wiredtiger.h> -static const char * const progname = "ex_event_handler"; static const char *home; int handle_wiredtiger_error( @@ -96,6 +96,17 @@ main(void) WT_SESSION *session; int ret; + /* + * Create a clean test directory for this run of the test program if the + * environment variable isn't already set (as is done by make check). + */ + if (getenv("WIREDTIGER_HOME") == NULL) { + home = "WT_HOME"; + ret = system("rm -rf WT_HOME && mkdir WT_HOME"); + } else + home = NULL; + + { /*! [Configure event_handler] */ CUSTOM_EVENT_HANDLER event_handler; @@ -109,6 +120,7 @@ main(void) ret = wiredtiger_open(home, (WT_EVENT_HANDLER *)&event_handler, "create", &conn); /*! [Configure event_handler] */ + } /* Make an invalid API call, to ensure the event handler works. */ (void)conn->open_session(conn, NULL, "isolation=invalid", &session); |