[LPC] 关于LWIP拔网线后阻塞,插上网线无法重连的问题

[复制链接]
8891|9
 楼主| iOrac 发表于 2014-6-25 15:17 | 显示全部楼层 |阅读模式
测试过程:先连接上服务器,然后拔掉网线,就阻塞在

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,即连接断开,一直这样,无法连接,求大侠指导!!怎么才能重新连接上服务器。。。。
beyond696 发表于 2014-6-25 15:26 | 显示全部楼层
得重新建立连接吧...
 楼主| iOrac 发表于 2014-6-25 18:01 | 显示全部楼层
beyond696 发表于 2014-6-25 15:26
得重新建立连接吧...

一直都有重新连接,关闭原来的socket,再按照流程进行连接,但连接过程中邮箱收的conn->err一直都是ERR_ABRT....
 楼主| iOrac 发表于 2014-7-15 16:36 | 显示全部楼层
移植了最新版本lwip1.4.1解决了发送阻塞的问题
_L_D_H_ 发表于 2014-7-28 00:18 | 显示全部楼层
跟版本没多大关系吧!
yangliu8623 发表于 2015-7-25 11:59 | 显示全部楼层
我也遇到这样的问题了,我的版本就是1.4.1的
申小林一号 发表于 2015-11-26 17:23 | 显示全部楼层
请问一下楼主,问题原因出现在哪里?
120742915 发表于 2016-10-19 16:02 | 显示全部楼层
我也出现这个问题了
w_乐天 发表于 2016-11-22 13:52 | 显示全部楼层
中断触发重联吧
Ccode11 发表于 2017-5-11 13:59 | 显示全部楼层

我也出现这个问题了,楼主怎么解决的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

3

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部