-/* $OpenBSD: rde.c,v 1.587 2023/01/17 16:09:01 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.588 2023/01/18 13:20:00 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
}
}
- if (rib_dump_pending() || rde_update_queue_pending() ||
- nexthop_pending() || peer_imsg_pending())
+ if (peer_imsg_pending() || rde_update_queue_pending() ||
+ nexthop_pending() || rib_dump_pending())
timeout = 0;
if (poll(pfd, i, timeout) == -1) {
-/* $OpenBSD: rde_peer.c,v 1.25 2022/09/23 15:49:20 claudio Exp $ */
+/* $OpenBSD: rde_peer.c,v 1.26 2023/01/18 13:20:01 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
struct peer_tree peertable;
struct rde_peer *peerself;
+static long imsg_pending;
CTASSERT(sizeof(peerself->recv_eor) * 8 > AID_MAX);
CTASSERT(sizeof(peerself->sent_eor) * 8 > AID_MAX);
fatal(NULL);
imsg_move(&iq->imsg, imsg);
SIMPLEQ_INSERT_TAIL(&peer->imsg_queue, iq, entry);
+ imsg_pending++;
}
/*
SIMPLEQ_REMOVE_HEAD(&peer->imsg_queue, entry);
free(iq);
+ imsg_pending--;
return 1;
}
-static void
-peer_imsg_queued(struct rde_peer *peer, void *arg)
-{
- int *p = arg;
-
- *p = *p || !SIMPLEQ_EMPTY(&peer->imsg_queue);
-}
-
/*
* Check if any imsg are pending, return 0 if none are pending
*/
int
peer_imsg_pending(void)
{
- int pending = 0;
-
- peer_foreach(peer_imsg_queued, &pending);
-
- return pending;
+ return imsg_pending != 0;
}
/*
while ((iq = SIMPLEQ_FIRST(&peer->imsg_queue)) != NULL) {
SIMPLEQ_REMOVE_HEAD(&peer->imsg_queue, entry);
free(iq);
+ imsg_pending--;
}
}