static pid_t dgm_pid = 0;
static struct msg_dgm_ref *refs = NULL;
+static struct msg_dgm_ref *next_ref = NULL;
static int msg_dgm_ref_destructor(struct msg_dgm_ref *r);
static void msg_dgm_ref_recv(struct tevent_context *ev,
const uint8_t *msg, size_t msg_len,
int *fds, size_t num_fds, void *private_data)
{
- struct msg_dgm_ref *r, *next;
+ struct msg_dgm_ref *r;
/*
* We have to broadcast incoming messages to all refs. The first ref
* that grabs the fd's will get them.
*/
- for (r = refs; r != NULL; r = next) {
+ for (r = refs; r != NULL; r = next_ref) {
bool active;
- next = r->next;
+ next_ref = r->next;
active = messaging_dgm_fde_active(r->fde);
if (!active) {
if (refs == NULL) {
abort();
}
+
+ if (r == next_ref) {
+ next_ref = r->next;
+ }
+
DLIST_REMOVE(refs, r);
TALLOC_FREE(r->fde);