NOTE: Don't do any fancy stuff in this wrapper which can cause the process to go into DEADLOCK
| 270 | // NOTE: Don't do any fancy stuff in this wrapper which can cause the process |
| 271 | // to go into DEADLOCK |
| 272 | void |
| 273 | ThreadSync::wrapperExecutionLockUnlock() |
| 274 | { |
| 275 | int saved_errno = errno; |
| 276 | |
| 277 | // The process is still initializing. We don't need to acquire lock. |
| 278 | if (WorkerState::currentState() == WorkerState::UNKNOWN) { |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | Thread *thread = dmtcp_get_current_thread(); |
| 283 | |
| 284 | JASSERT(thread->wrapperLockCount != 0); |
| 285 | thread->wrapperLockCount -= 1; |
| 286 | |
| 287 | if (thread->wrapperLockCount == 0 && |
| 288 | DmtcpRWLockUnlock(&_wrapperExecutionLock) != 0) { |
| 289 | fprintf(stderr, "ERROR %s:%d %s: Failed to release lock.\n", |
| 290 | __FILE__, __LINE__, __PRETTY_FUNCTION__); |
| 291 | _exit(DMTCP_FAIL_RC); |
| 292 | } |
| 293 | |
| 294 | errno = saved_errno; |
| 295 | } |
| 296 | |
| 297 | // GNU g++ uses __thread. But the C++0x standard says to use thread_local. |
| 298 | // If your compiler fails here, you can: change "__thread" to "thread_local"; |
nothing calls this directly
no test coverage detected