static void sync_close_buddy(struct sync_buddy *buddy)
{
- if (buddy->fd < 0)
- return;
- PARA_DEBUG_LOG("closing %s\n", buddy->sbi->url);
+ PARA_DEBUG_LOG("closing %s, fd %d\n", buddy->sbi->url, buddy->fd);
close(buddy->fd);
- buddy->fd = -1;
+ list_del(&buddy->node);
+ free(buddy);
}
static void sync_close_buddies(struct sync_filter_context *ctx)
{
- struct sync_buddy *buddy;
+ struct sync_buddy *buddy, *tmp;
- FOR_EACH_BUDDY(buddy, &ctx->buddies)
+ FOR_EACH_BUDDY_SAFE(buddy, tmp, &ctx->buddies)
sync_close_buddy(buddy);
}
FOR_EACH_BUDDY(buddy, &ctx->buddies) {
if (buddy->sbi->disabled)
continue;
+ if (buddy->ping_received == true)
+ continue;
PARA_NOTICE_LOG("disabling %s\n", buddy->sbi->url);
buddy->sbi->disabled = true;
}
buddy->sbi->url, buddy->sbi->disabled?
"disabled" : "enabled");
ret = xwrite(buddy->fd, &c, 1);
- sync_close_buddy(buddy);
if (ret < 0) {
PARA_WARNING_LOG("failed to write to %s: %s\n",
buddy->sbi->url, para_strerror(-ret));
- list_del(&buddy->node);
+ sync_close_buddy(buddy);
}
}
ctx->ping_sent = true;
buddy->sbi->url);
buddy->sbi->disabled = false;
}
- list_del(&buddy->node);
+ buddy->ping_received = true;
}
}
if (!sync_complete(ctx))