From 0c3c6bf2b7688562910e78727bd41fbd85fe6356 Mon Sep 17 00:00:00 2001 From: kefren Date: Sat, 22 Jan 2011 19:35:00 +0000 Subject: [PATCH] use SLIST_FOREACH_SAFE when deleting a peer in loop --- usr.sbin/ldpd/socketops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ldpd/socketops.c b/usr.sbin/ldpd/socketops.c index 83e63babde13..88d344c55c8c 100644 --- a/usr.sbin/ldpd/socketops.c +++ b/usr.sbin/ldpd/socketops.c @@ -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,