MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / example_db_event_hook

Function example_db_event_hook

test/plugin/example-db/example-db.cpp:77–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77static void
78example_db_event_hook(DmtcpEvent_t event, DmtcpEventData_t *data)
79{
80 /* NOTE: See warning in plugin/README about calls to printf here. */
81 switch (event) {
82 case DMTCP_EVENT_INIT:
83 printf("The plugin containing %s has been initialized.\n", __FILE__);
84 if (getenv("EXAMPLE_DB_KEY")) {
85 strcpy(mystruct.key, getenv("EXAMPLE_DB_KEY"));
86 mystruct.pid = getpid();
87 printf(" Data initialized: My (key, pid) is: (%s, %ld).\n",
88 mystruct.key, (long)mystruct.pid);
89 }
90 if (getenv("EXAMPLE_DB_KEY_OTHER")) {
91 strcpy(mystruct_other.key, getenv("EXAMPLE_DB_KEY_OTHER"));
92 mystruct_other.pid = -1; /* -1 means unknown */
93 }
94 break;
95
96 case DMTCP_EVENT_PRECHECKPOINT:
97 checkpoint();
98 break;
99
100 case DMTCP_EVENT_RESUME:
101 registerNSData();
102 dmtcp_global_barrier("ExampleDb::Resume");
103 sendQueries();
104 break;
105
106 case DMTCP_EVENT_RESTART:
107 registerNSData();
108 dmtcp_global_barrier("ExampleDb::Restart");
109 sendQueries();
110 break;
111
112 default:
113 break;
114 }
115}
116
117DmtcpPluginDescriptor_t example_db_plugin = {
118 DMTCP_PLUGIN_API_VERSION,

Callers

nothing calls this directly

Calls 5

registerNSDataFunction · 0.85
dmtcp_global_barrierFunction · 0.85
sendQueriesFunction · 0.85
checkpointFunction · 0.70
getpidFunction · 0.50

Tested by

no test coverage detected