lib/netdb: Rename dns_sem[take|give] with dns_[lock|unlock]

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-11-10 01:23:22 +08:00 committed by Petro Karashchenko
parent 898093a822
commit 36abcda0d2
7 changed files with 37 additions and 37 deletions

View File

@ -132,24 +132,24 @@ EXTERN uint8_t g_dns_nservers;
****************************************************************************/
/****************************************************************************
* Name: dns_semtake
* Name: dns_lock
*
* Description:
* Take the DNS semaphore, ignoring errors due to the receipt of signals.
* Take the DNS mutex, ignoring errors due to the receipt of signals.
*
****************************************************************************/
void dns_semtake(void);
void dns_lock(void);
/****************************************************************************
* Name: dns_semgive
* Name: dns_unlock
*
* Description:
* Release the DNS semaphore
* Release the DNS mutex
*
****************************************************************************/
void dns_semgive(void);
void dns_unlock(void);
/****************************************************************************
* Name: dns_bind

View File

@ -134,7 +134,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
return ret;
}
dns_semtake();
dns_lock();
#ifdef CONFIG_NET_IPv4
/* Check for an IPv4 address */
@ -243,7 +243,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
ret = OK;
errout:
dns_semgive();
dns_unlock();
fclose(stream);
if (ret == OK)
@ -269,7 +269,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
/* Get the index of the next free nameserver slot. */
dns_semtake();
dns_lock();
if (g_dns_nservers == CONFIG_NETDB_DNSSERVER_NAMESERVERS)
{
idx = 0;
@ -308,7 +308,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
#endif
{
nerr("ERROR: Unsupported family: %d\n", addr->sa_family);
dns_semgive();
dns_unlock();
return -ENOSYS;
}
@ -318,7 +318,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
{
nerr("ERROR: Invalid addrlen %ld for family %d\n",
(long)addrlen, addr->sa_family);
dns_semgive();
dns_unlock();
return -EINVAL;
}
@ -334,7 +334,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
ret = dns_foreach_nameserver(dns_check_nameserver, &dns_addr.addr);
if (ret < 0)
{
dns_semgive();
dns_unlock();
return ret;
}
@ -343,7 +343,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
/* We now have a valid DNS address */
g_dns_nservers = nservers;
dns_semgive();
dns_unlock();
#if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0
dns_clear_answer();
#endif

View File

@ -105,7 +105,7 @@ void dns_save_answer(FAR const char *hostname,
/* Get exclusive access to the DNS cache */
dns_semtake();
dns_lock();
/* Get the index to the new head of the list */
@ -149,7 +149,7 @@ void dns_save_answer(FAR const char *hostname,
/* Save the updated head index */
g_dns_head = next;
dns_semgive();
dns_unlock();
}
/****************************************************************************
@ -167,14 +167,14 @@ void dns_clear_answer(void)
{
/* Get exclusive access to the DNS cache */
dns_semtake();
dns_lock();
/* Reset the circular of DNS cache */
g_dns_head = 0;
g_dns_tail = 0;
dns_semgive();
dns_unlock();
}
/****************************************************************************
@ -213,7 +213,7 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
/* Get exclusive access to the DNS cache */
dns_semtake();
dns_lock();
#if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0
/* Get the current time */
@ -274,7 +274,7 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
memcpy(addr, &entry->addr, *naddr * sizeof(*addr));
dns_semgive();
dns_unlock();
return OK;
}
}
@ -282,7 +282,7 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
ret = -ENOENT;
dns_semgive();
dns_unlock();
return ret;
}

View File

@ -57,9 +57,9 @@ int dns_default_nameserver(void)
#else /* CONFIG_NETDB_RESOLVCONF */
int dns_default_nameserver(void)
{
dns_semtake();
dns_lock();
g_dns_nservers = 0;
dns_semgive();
dns_unlock();
return OK;
}
#endif /* CONFIG_NETDB_RESOLVCONF */

View File

@ -96,7 +96,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
return ret;
}
dns_semtake();
dns_lock();
keylen = strlen(NETDB_DNS_KEYWORD);
while (fgets(line, DNS_MAX_LINE, stream) != NULL)
@ -225,7 +225,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
}
}
dns_semgive();
dns_unlock();
fclose(stream);
return ret;
}
@ -238,7 +238,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
int ret = OK;
int i;
dns_semtake();
dns_lock();
for (i = 0; i < g_dns_nservers; i++)
{
#ifdef CONFIG_NET_IPv4
@ -290,7 +290,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
}
}
dns_semgive();
dns_unlock();
return ret;
}

View File

@ -47,27 +47,27 @@ static rmutex_t g_dns_lock = NXRMUTEX_INITIALIZER;
****************************************************************************/
/****************************************************************************
* Name: dns_semtake
* Name: dns_lock
*
* Description:
* Take the DNS lock, ignoring errors due to the receipt of signals.
*
****************************************************************************/
void dns_semtake(void)
void dns_lock(void)
{
nxrmutex_lock(&g_dns_lock);
}
/****************************************************************************
* Name: dns_semgive
* Name: dns_unlock
*
* Description:
* Release the DNS lock
*
****************************************************************************/
void dns_semgive(void)
void dns_unlock(void)
{
nxrmutex_unlock(&g_dns_lock);
}

View File

@ -74,9 +74,9 @@ int dns_register_notify(dns_callback_t callback, FAR void *arg)
notify->callback = callback;
notify->arg = arg;
dns_semtake();
dns_lock();
dq_addlast(&notify->entry, &g_dns_notify);
dns_semgive();
dns_unlock();
/* Notify the existed nameserver */
@ -96,7 +96,7 @@ int dns_unregister_notify(dns_callback_t callback, FAR void *arg)
{
FAR dq_entry_t *entry;
dns_semtake();
dns_lock();
for (entry = dq_peek(&g_dns_notify); entry; entry = dq_next(entry))
{
FAR struct dns_notify_s *notify = (FAR struct dns_notify_s *)entry;
@ -104,13 +104,13 @@ int dns_unregister_notify(dns_callback_t callback, FAR void *arg)
if (notify->callback == callback && notify->arg == arg)
{
dq_rem(&notify->entry, &g_dns_notify);
dns_semgive();
dns_unlock();
lib_free(notify);
return OK;
}
}
dns_semgive();
dns_unlock();
return -EINVAL;
}
@ -123,14 +123,14 @@ void dns_notify_nameserver(FAR const struct sockaddr *addr,
{
FAR dq_entry_t *entry;
dns_semtake();
dns_lock();
for (entry = dq_peek(&g_dns_notify); entry; entry = dq_next(entry))
{
FAR struct dns_notify_s *notify = (FAR struct dns_notify_s *)entry;
notify->callback(notify->arg, (FAR struct sockaddr *)addr, addrlen);
}
dns_semgive();
dns_unlock();
}
#endif /* CONFIG_NETDB_DNSCLIENT */