1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-06-09 12:03:41 +02:00

Land - Fix threads in POSIX

This commit is contained in:
OJ 2016-04-06 10:59:01 +10:00
commit fe048683c9
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597
2 changed files with 94 additions and 95 deletions
c/meterpreter/source/common

@ -23,15 +23,14 @@ int __futex_wake(volatile void *ftx, int count);
*/
LOCK * lock_create(VOID)
{
LOCK * lock = (LOCK *)malloc( sizeof( LOCK ) );
LOCK * lock = calloc(1, sizeof(LOCK));
if (lock != NULL)
{
memset( lock, 0, sizeof( LOCK ) );
#ifdef _WIN32
lock->handle = CreateMutex(NULL, FALSE, NULL);
#else
pthread_mutex_init(lock->handle, NULL);
pthread_mutex_init(&lock->handle, NULL);
#endif
}
return lock;
@ -49,7 +48,7 @@ VOID lock_destroy( LOCK * lock )
#ifdef _WIN32
CloseHandle(lock->handle);
#else
pthread_mutex_destroy(lock->handle);
pthread_mutex_destroy(&lock->handle);
#endif
free(lock);
@ -65,7 +64,7 @@ VOID lock_acquire( LOCK * lock )
#ifdef _WIN32
WaitForSingleObject(lock->handle, INFINITE);
#else
pthread_mutex_lock(lock->handle);
pthread_mutex_lock(&lock->handle);
#endif
}
}
@ -79,7 +78,7 @@ VOID lock_release( LOCK * lock )
#ifdef _WIN32
ReleaseMutex(lock->handle);
#else
pthread_mutex_unlock(lock->handle);
pthread_mutex_unlock(&lock->handle);
#endif
}
}

@ -44,7 +44,7 @@ typedef struct _LOCK
#ifdef _WIN32
HANDLE handle;
#else
pthread_mutex_t *handle;
pthread_mutex_t handle;
#endif // _WIN32
} LOCK, * LPLOCK;