When a 'ping' (empty message) is sent to mdmon, we wait for
'monitor' to do a full loop to make sure it has caught up
with anything that needs doing.
This allows synchronisation between mdadm and mdmon.
Maybe monitor should signal managemon rather than managemon polling...
Signed-off-by: Neil Brown <neilb@suse.de>
struct metadata_update *mu;
if (msg->len == 0) {
struct metadata_update *mu;
if (msg->len == 0) {
+ int cnt = monitor_loop_cnt;
+ if (cnt & 1)
+ cnt += 2; /* wait until next pselect */
+ else
+ cnt += 3; /* wait for 2 pselects */
+ wakeup_monitor();
+ while (monitor_loop_cnt - cnt < 0)
+ usleep(10 * 1000);
} else {
mu = malloc(sizeof(*mu));
mu->len = msg->len;
} else {
mu = malloc(sizeof(*mu));
mu->len = msg->len;
extern int exit_now, manager_ready;
extern int mon_tid, mgr_tid;
extern int exit_now, manager_ready;
extern int mon_tid, mgr_tid;
+extern int monitor_loop_cnt;
static int wait_and_act(struct supertype *container, int nowait)
{
fd_set rfds;
static int wait_and_act(struct supertype *container, int nowait)
{
fd_set rfds;
sigset_t set;
sigprocmask(SIG_UNBLOCK, NULL, &set);
sigdelset(&set, SIGUSR1);
sigset_t set;
sigprocmask(SIG_UNBLOCK, NULL, &set);
sigdelset(&set, SIGUSR1);
rv = pselect(maxfd+1, &rfds, NULL, NULL, NULL, &set);
rv = pselect(maxfd+1, &rfds, NULL, NULL, NULL, &set);
if (rv == -1 && errno == EINTR)
rv = 0;
#ifdef DEBUG
if (rv == -1 && errno == EINTR)
rv = 0;
#ifdef DEBUG