void *dlopen(const char *filename, int flag)
{
  bool lockAcquired = dmtcp::ThreadSync::libdlLockLock();
  void *ret = _real_dlopen(filename, flag);
  if (lockAcquired) {
    dmtcp::ThreadSync::libdlLockUnlock();
  }
  return ret;
}
示例#2
0
/*
 * WARNING: By using this method to initialize libpthread wrappers (direct
 * dlopen()/dlsym()) we are are overriding any user wrappers for these
 * functions. If this is a problem in the future we need to think of a new way
 * to do this.
 */
LIB_PRIVATE
void initialize_libpthread_wrappers()
{
  if (!_libpthread_wrappers_initialized) {
    dmtcp_setThreadPerformingDlopenDlsym();
    void *pthread_handle = _real_dlopen(LIBPTHREAD_FILENAME, RTLD_NOW);
    dmtcp_unsetThreadPerformingDlopenDlsym();

    if (pthread_handle == NULL) {
      fprintf(stderr, "*** DMTCP: Error: could not open libpthread shared "
                      "library. Aborting.\n");
      abort();
    }
    FOREACH_LIBPTHREAD_WRAPPERS(GET_LIBPTHREAD_FUNC_ADDR);
    _real_dlclose(pthread_handle);

    _libpthread_wrappers_initialized = 1;
  }
}