Chinaunix首页 | 论坛 | 博客
  • 博客访问: 304546
  • 博文数量: 118
  • 博客积分: 313
  • 博客等级: 二等列兵
  • 技术积分: 615
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-12 22:51
文章分类

全部博文(118)

文章存档

2012年(68)

2011年(50)

分类:

2011-12-01 23:34:14

一个客户的发现我们的设备上出现了arpFlush处挂起的现象,看了一下代码,发现arpFlush中存在竞争条件,即代码中获取arp_llinfo链表信息时,没有处于spnet之下,所以会导致原本有效的链表节点,在进入spnet保护的临界区之后,实际上可能被其它任务释放,从而导致任务挂起。代码如下,出问题的就是第一行代码。

  1. void arpFlush (void)
  2.     {
  3.     struct llinfo_arp * la = arp_llinfo.lh_first;
  4.     struct llinfo_arp * ola;
  5.     struct rtentry *rt;
  6.     int    s;

  7.     s = splnet ();

  8.     while ((ola = la) != 0)
  9.     {
  10.         rt = la->la_rt;
  11.     la = la->la_le.le_next;

  12.     /* if entry permanent */
  13.     if ((rt->rt_rmx.rmx_expire == 0) || (rt->rt_flags == 0))
  14.      continue;

  15.     arptfree(ola); /* timer has expired; clear */
  16.     }

  17.     splx (s);
  18.     }
阅读(632) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~