测试过程:先连接上服务器,然后拔掉网线,就阻塞在
void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
{
u32_t time;
struct sys_timeouts *timeouts;
struct sys_timeout *tmptimeout;
sys_timeout_handler h;
void *arg;
again:
timeouts = sys_arch_timeouts();
if (!timeouts || !timeouts->next) {
sys_arch_mbox_fetch(mbox, msg, 0);
} else {
if (timeouts->next->time > 0) {
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
} else {
time = SYS_ARCH_TIMEOUT;
}
if (time == SYS_ARCH_TIMEOUT) {
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
could be fetched. We should now call the timeout handler and
deallocate the memory allocated for the timeout. */
tmptimeout = timeouts->next;
timeouts->next = tmptimeout->next;
h = tmptimeout->h;
arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg));
h(arg);
}
/* We try again to fetch a message from the mbox. */
goto again;
}
else
{
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
occured. The time variable is set to the number of
milliseconds we waited for the message. */
if (time <= timeouts->next->time) {
timeouts->next->time -= time;
} else {
timeouts->next->time = 0;
}
}
}
}
仿真发现 老是运行到 time = SYS_ARCH_TIMEOUT;,然后跳回again。发送函数netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)总是返回一个ERR_MEM,是内存分配错误。然后我插上网线,永远也连接不上服务器了,执行连接函数后err_t
netconn_connect(struct netconn *conn, struct ip_addr *addr,
u16_t port)
执行里面的sys_mbox_fetch(conn->mbox, NULL),返回的conn->err为0xFD,即-3,LWIP定义相应的宏为ERR_ABRT,即连接断开,一直这样,无法连接,求大侠指导!!怎么才能重新连接上服务器。。。。 |