Work around sem_unlink bug on FreeBSD when /tmp is using tmpfs
PR: 189353
This commit is contained in:
parent
f031afd4f3
commit
75daa7974d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=458923
2 changed files with 38 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
PORTNAME= yara
|
||||
PORTVERSION= 3.7.0
|
||||
PORTREVISION= 1
|
||||
DISTVERSIONPREFIX= v
|
||||
CATEGORIES= security
|
||||
|
||||
|
|
37
security/yara/files/patch-threading.c
Normal file
37
security/yara/files/patch-threading.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Work around FreeBSD bug #189353 when /tmp is using tmpfs(5)
|
||||
|
||||
--- threading.c.orig 2017-11-10 11:21:21 UTC
|
||||
+++ threading.c
|
||||
@@ -33,6 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
+#if defined(__FreeBSD__)
|
||||
+#include <stdlib.h>
|
||||
+#endif
|
||||
+
|
||||
#include "threading.h"
|
||||
|
||||
|
||||
@@ -88,6 +92,11 @@ int semaphore_init(
|
||||
*semaphore = CreateSemaphore(NULL, value, 65535, NULL);
|
||||
if (*semaphore == NULL)
|
||||
return GetLastError();
|
||||
+ #elif defined(__FreeBSD__)
|
||||
+ *semaphore = malloc(sizeof(sem_t));
|
||||
+ if (*semaphore == NULL)
|
||||
+ return errno;
|
||||
+ return sem_init(*semaphore, 0, value);
|
||||
#else
|
||||
// Mac OS X doesn't support unnamed semaphores via sem_init, that's why
|
||||
// we use sem_open instead sem_init and immediately unlink the semaphore
|
||||
@@ -112,6 +121,9 @@ void semaphore_destroy(
|
||||
{
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
CloseHandle(*semaphore);
|
||||
+ #elif defined(__FreeBSD__)
|
||||
+ sem_close(*semaphore);
|
||||
+ free(*semaphore);
|
||||
#else
|
||||
sem_close(*semaphore);
|
||||
#endif
|
Loading…
Reference in a new issue