| 75 | |
| 76 | |
| 77 | static void |
| 78 | example_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 | |
| 117 | DmtcpPluginDescriptor_t example_db_plugin = { |
| 118 | DMTCP_PLUGIN_API_VERSION, |
nothing calls this directly
no test coverage detected