[Forensics-changes] [yara] 63/192: Windows mutex replaced with CriticalSection
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:31:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.6.0
in repository yara.
commit 245edc994b2c8c0a9753a0f690e186d2fb513dd0
Author: Rastislav Masaryk <rmasaryk at eset.sk>
Date: Fri Nov 11 10:15:57 2016 +0100
Windows mutex replaced with CriticalSection
---
threading.c | 13 +++++--------
threading.h | 2 +-
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/threading.c b/threading.c
index 5257884..5a65c2e 100644
--- a/threading.c
+++ b/threading.c
@@ -40,11 +40,8 @@ int mutex_init(
MUTEX* mutex)
{
#if defined(_WIN32) || defined(__CYGWIN__)
- *mutex = CreateMutex(NULL, FALSE, NULL);
- if (*mutex == NULL)
- return GetLastError();
- else
- return 0;
+ InitializeCriticalSection(mutex);
+ return GetLastError();
#else
return pthread_mutex_init(mutex, NULL);
#endif
@@ -54,7 +51,7 @@ void mutex_destroy(
MUTEX* mutex)
{
#if defined(_WIN32) || defined(__CYGWIN__)
- CloseHandle(*mutex);
+ DeleteCriticalSection(mutex);
#else
pthread_mutex_destroy(mutex);
#endif
@@ -65,7 +62,7 @@ void mutex_lock(
MUTEX* mutex)
{
#if defined(_WIN32) || defined(__CYGWIN__)
- WaitForSingleObject(*mutex, INFINITE);
+ EnterCriticalSection(mutex);
#else
pthread_mutex_lock(mutex);
#endif
@@ -76,7 +73,7 @@ void mutex_unlock(
MUTEX* mutex)
{
#if defined(_WIN32) || defined(__CYGWIN__)
- ReleaseMutex(*mutex);
+ LeaveCriticalSection(mutex);
#else
pthread_mutex_unlock(mutex);
#endif
diff --git a/threading.h b/threading.h
index d6bf46a..43a68b6 100644
--- a/threading.h
+++ b/threading.h
@@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if defined(_WIN32) || defined(__CYGWIN__)
typedef HANDLE SEMAPHORE;
-typedef HANDLE MUTEX;
+typedef CRITICAL_SECTION MUTEX;
typedef HANDLE THREAD;
typedef LPTHREAD_START_ROUTINE THREAD_START_ROUTINE;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list