summaryrefslogtreecommitdiff
path: root/examples/c/ex_rep/common/rep_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/c/ex_rep/common/rep_common.h')
-rw-r--r--examples/c/ex_rep/common/rep_common.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/examples/c/ex_rep/common/rep_common.h b/examples/c/ex_rep/common/rep_common.h
index edf3b67d..8f7d1348 100644
--- a/examples/c/ex_rep/common/rep_common.h
+++ b/examples/c/ex_rep/common/rep_common.h
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2006, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*/
@@ -33,6 +33,7 @@ typedef struct {
int is_master;
int app_finished;
int in_client_sync;
+ int is_repmgr;
} SHARED_DATA;
/* Arguments for support threads. */
@@ -41,6 +42,15 @@ typedef struct {
SHARED_DATA *shared;
} supthr_args;
+/*
+ * Per-thread Replication Manager structure to associate a PERM_FAILED event
+ * with its originating transaction.
+ */
+typedef struct {
+ char *thread_name;
+ int flag;
+} permfail_t;
+
/* Portability macros for basic threading & timing */
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@@ -59,6 +69,16 @@ typedef HANDLE thread_t;
((WaitForSingleObject((thr), INFINITE) == WAIT_OBJECT_0) && \
GetExitCodeThread((thr), (LPDWORD)(statusp)) ? 0 : -1)
+/* Thread-specific data key for PERM_FAILED structure for Windows. */
+extern DWORD permfail_key;
+/* Thread local storage routine definitions for Windows. */
+#define thread_key_create(keyp) ((*keyp = TlsAlloc()) == \
+ TLS_OUT_OF_INDEXES ? (int)GetLastError() : 0)
+#define thread_key_delete(key) (TlsFree(key) ? 0 : (int)GetLastError())
+#define thread_setspecific(key, value) (TlsSetValue(key, value) ? 0 : \
+ (int)GetLastError())
+#define thread_getspecific(key) TlsGetValue(key)
+
#else /* !_WIN32 */
#include <sys/time.h>
#include <pthread.h>
@@ -68,6 +88,14 @@ typedef pthread_t thread_t;
pthread_create((thrp), (attr), (func), (arg))
#define thread_join(thr, statusp) pthread_join((thr), (statusp))
+/* Thread-specific data key for PERM_FAILED structure for Posix. */
+extern pthread_key_t permfail_key;
+/* Thread local storage routine definitions for Posix. */
+#define thread_key_create(keyp) pthread_key_create(keyp, NULL)
+#define thread_key_delete(key) pthread_key_delete(key)
+#define thread_setspecific(key, value) pthread_setspecific(key, value)
+#define thread_getspecific(key) pthread_getspecific(key)
+
#endif
void *checkpoint_thread __P((void *));