mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 04:09:26 +08:00
mDNS: Use mutex for mDNSPosix platform
This commit is contained in:
parent
f7205c1ed6
commit
0543f16e4c
@ -1220,6 +1220,9 @@ mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
|
||||
{
|
||||
int err = 0;
|
||||
struct sockaddr sa;
|
||||
#ifdef __rtems__
|
||||
pthread_mutexattr_t attr;
|
||||
#endif /* __rtems__ */
|
||||
assert(m != NULL);
|
||||
|
||||
if (mDNSPlatformInit_CanReceiveUnicast()) m->CanReceiveUnicastOn5353 = mDNStrue;
|
||||
@ -1237,6 +1240,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
|
||||
if (m->hostlabel.c[0] == 0) MakeDomainLabelFromLiteralString(&m->hostlabel, "Computer");
|
||||
|
||||
mDNS_SetFQDN(m);
|
||||
#ifdef __rtems__
|
||||
if (err == mStatus_NoError) err = pthread_mutexattr_init(&attr);
|
||||
if (err == mStatus_NoError) err = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
|
||||
if (err == mStatus_NoError) err = pthread_mutex_init(&m->p->mutex, &attr);
|
||||
if (err == mStatus_NoError) err = pthread_mutexattr_destroy(&attr);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
sa.sa_family = AF_INET;
|
||||
m->p->unicastSocket4 = -1;
|
||||
@ -1306,14 +1315,22 @@ mDNSexport mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m)
|
||||
// the platform from reentering mDNS core code.
|
||||
mDNSexport void mDNSPlatformLock (const mDNS *const m)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
(void) m; // Unused
|
||||
#else /* __rtems__ */
|
||||
pthread_mutex_lock(&m->p->mutex);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
// mDNS core calls this routine when it release the lock taken by
|
||||
// mDNSPlatformLock and allow the platform to reenter mDNS core code.
|
||||
mDNSexport void mDNSPlatformUnlock (const mDNS *const m)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
(void) m; // Unused
|
||||
#else /* __rtems__ */
|
||||
pthread_mutex_unlock(&m->p->mutex);
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
||||
#if COMPILER_LIKES_PRAGMA_MARK
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef __rtems__
|
||||
#include <pthread.h>
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -54,6 +57,9 @@ struct mDNS_PlatformSupport_struct
|
||||
#if HAVE_IPV6
|
||||
int unicastSocket6;
|
||||
#endif
|
||||
#ifdef __rtems__
|
||||
pthread_mutex_t mutex;
|
||||
#endif /* __rtems__ */
|
||||
};
|
||||
|
||||
#define uDNS_SERVERS_FILE "/etc/resolv.conf"
|
||||
|
Loading…
x
Reference in New Issue
Block a user