[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #46887] The issue about gethostbyname() function
From: |
kaiqin lin |
Subject: |
[lwip-devel] [bug #46887] The issue about gethostbyname() function |
Date: |
Wed, 13 Jan 2016 03:51:34 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0 |
URL:
<http://savannah.nongnu.org/bugs/?46887>
Summary: The issue about gethostbyname() function
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: lin704932121
Submitted on: Wed 13 Jan 2016 03:51:32 AM GMT
Category: DNS
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release:
lwIP version: git head
_______________________________________________________
Details:
I have a project using lwip stack with uCOS-III RTOS. lwip version is
lwip-37bb0b89f062ed4fc47f0e42146dfdb065e1d6c4 that is from git.
My application thread priority is higher than lwip tcpip_thread priority.
When application call gethostbyname(), My RTOS detect the parameter *sem of
sys_sem_signal() is uncorrect object type. After debug, I find the problem.
The gethostbyname() calling procedure is that:
lwip_gethostbyname()
netconn_gethostbyname_addrtype()
tcpip_callback(lwip_netconn_do_gethostbyname,
&API_VAR_REF(msg));
sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem));
sys_sem_free(API_EXPR_REF(API_VAR_REF(msg).sem));
When application thread execute to sys_sem_wait() above, it will block.
Then lwip tcpip_thread will call lwip_netconn_do_gethostbyname(msg) function
whose calling procedure is that:
lwip_netconn_do_gethostbyname()
dns_gethostbyname_addrtype()
dns_enqueue()
dns_check_entry() dns.c:1379
dns_send() dns.c:985
dns_call_found() dns.c:735
lwip_netconn_do_dns_found(arg) dns.c:899
msg->err = ERR_VAL
sys_sem_signal(msg->sem)
After calling sys_sem_signal(msg->sem) function, application thread will
run again immediately since its priority is higher than lwip tcpip_thread.
Then application thread will free msg->sem by calling sys_sem_free().
Once lwip tcpip_thread continue to run, lwip_netconn_do_gethostbyname() will
check msg->err if unequal to ERR_INPROGRESS. Because msg->err is set to
ERR_VAL above, so sys_sem_signal(msg->sem) will be called.However, msg->sem
is freed already.
This output info by usart is that:
dns_enqueue: "www.baidu.com": use DNS entry 0
dns_enqueue: "www.baidu.com": use DNS pcb 0
dns_send: dns_servers[0] "www.baidu.com": request
lwip_gethostbyname(www.baidu.com) failed, err=-6
Could not find host www.baidu.com
sys_sem_signal: err:24004
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 13 Jan 2016 03:51:33 AM GMT Name: lwipopts.h Size: 6kB By:
lin704932121
<http://savannah.nongnu.org/bugs/download.php?file_id=36004>
-------------------------------------------------------
Date: Wed 13 Jan 2016 03:51:33 AM GMT Name: port.rar Size: 12kB By:
lin704932121
<http://savannah.nongnu.org/bugs/download.php?file_id=36005>
-------------------------------------------------------
Date: Wed 13 Jan 2016 03:51:33 AM GMT Name: app.rar Size: 8kB By:
lin704932121
<http://savannah.nongnu.org/bugs/download.php?file_id=36006>
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?46887>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [bug #46887] The issue about gethostbyname() function,
kaiqin lin <=