use SLIST_FOREACH_SAFE when deleting a peer in loop

This commit is contained in:
kefren 2011-01-22 19:35:00 +00:00
parent a3e123d017
commit 0c3c6bf2b7
1 changed files with 4 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: socketops.c,v 1.3 2010/12/30 11:29:21 kefren Exp $ */
/* $NetBSD: socketops.c,v 1.4 2011/01/22 19:35:00 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -457,7 +457,7 @@ recv_pdu(int sock)
void
send_hello_alarm(int unused)
{
struct ldp_peer *p;
struct ldp_peer *p, *ptmp;
struct hello_info *hi, *hinext;
time_t t = time(NULL);
int olderrno = errno;
@ -471,15 +471,14 @@ send_hello_alarm(int unused)
p->timeout--;
/* Check for timeout */
check_peer:
SLIST_FOREACH(p, &ldp_peer_head, peers)
SLIST_FOREACH_SAFE(p, &ldp_peer_head, peers, ptmp)
if (p->timeout < 1)
switch (p->state) {
case LDP_PEER_HOLDDOWN:
debugp("LDP holddown expired for peer %s\n",
inet_ntoa(p->ldp_id));
ldp_peer_delete(p);
goto check_peer;
break;
case LDP_PEER_ESTABLISHED:
case LDP_PEER_CONNECTED:
send_notification(p, 0,