Browse Source

*** debugging sequencing of sync_close()

wip/debug-various
Oswald Buddenhagen 3 years ago
parent
commit
36d8007d66
  1. 24
      src/sync.c

24
src/sync.c

@ -1448,17 +1448,22 @@ msgs_copied( sync_vars_t *svars, int t )
copy_vars_t *cv; copy_vars_t *cv;
if (svars->state[t] & ST_SENDING_NEW) if (svars->state[t] & ST_SENDING_NEW)
{ debug("sending new to %d\n", t);
return; return;
}
sync_ref( svars ); sync_ref( svars );
if (!(svars->state[t] & ST_SENT_NEW)) { if (!(svars->state[t] & ST_SENT_NEW)) {
for (tmsg = svars->new_msgs[t]; tmsg; tmsg = tmsg->next) { for (tmsg = svars->new_msgs[t]; tmsg; tmsg = tmsg->next) {
if (tmsg->status & M_DEAD) if (tmsg->status & M_DEAD)
{ debug("message %u for %d is dead\n", tmsg->uid, t);
continue; continue;
}
if ((srec = tmsg->srec) && (srec->status & S_PENDING)) { if ((srec = tmsg->srec) && (srec->status & S_PENDING)) {
if (svars->drv[t]->get_memory_usage( svars->ctx[t] ) >= BufferLimit) { if (svars->drv[t]->get_memory_usage( svars->ctx[t] ) >= BufferLimit) {
svars->new_msgs[t] = tmsg; svars->new_msgs[t] = tmsg;
debug("postponing message %u for %d\n", tmsg->uid, t);
goto out; goto out;
} }
new_total[t]++; new_total[t]++;
@ -1476,13 +1481,18 @@ msgs_copied( sync_vars_t *svars, int t )
if (check_cancel( svars )) if (check_cancel( svars ))
goto out; goto out;
} }
else
debug("message %u for %d is not pending (%s srec)\n", tmsg->uid, t, srec ? "with" : "NO");
} }
svars->state[t] |= ST_SENT_NEW; svars->state[t] |= ST_SENT_NEW;
} }
if (svars->new_pending[t]) if (svars->new_pending[t])
{ debug("%u new pending for %d\n", svars->new_pending[t], t);
goto out; goto out;
}
debug("sent new to %d\n", t);
sync_close( svars, t^1 ); sync_close( svars, t^1 );
if (check_cancel( svars )) if (check_cancel( svars ))
goto out; goto out;
@ -1514,6 +1524,7 @@ msgs_found_new( int sts, message_t *msgs, void *aux )
static void static void
msgs_new_done( sync_vars_t *svars, int t ) msgs_new_done( sync_vars_t *svars, int t )
{ {
debug( "found new messages on %s\n", str_fn[t] );
svars->state[t] |= ST_FOUND_NEW; svars->state[t] |= ST_FOUND_NEW;
sync_close( svars, t ); sync_close( svars, t );
} }
@ -1596,6 +1607,7 @@ msgs_flags_set( sync_vars_t *svars, int t )
sync_ref( svars ); sync_ref( svars );
debug( "set flags on %s\n", str_fn[t] );
sync_close( svars, t^1 ); sync_close( svars, t^1 );
if (check_cancel( svars )) if (check_cancel( svars ))
goto out; goto out;
@ -1718,6 +1730,7 @@ msgs_flags_set( sync_vars_t *svars, int t )
goto out; goto out;
} }
skip: skip:
debug( "sent trash from %s\n", str_fn[t] );
svars->state[t] |= ST_SENT_TRASH; svars->state[t] |= ST_SENT_TRASH;
sync_close( svars, t ); sync_close( svars, t );
@ -1747,6 +1760,7 @@ msg_trashed( int sts, void *aux )
free( vars ); free( vars );
trash_done[t]++; trash_done[t]++;
stats(); stats();
debug( "sent one trash from %s\n", str_fn[t] );
svars->trash_pending[t]--; svars->trash_pending[t]--;
if (check_cancel( svars )) if (check_cancel( svars ))
return; return;
@ -1780,6 +1794,7 @@ msg_rtrashed( int sts, uint uid ATTR_UNUSED, copy_vars_t *vars )
free( vars ); free( vars );
trash_done[t]++; trash_done[t]++;
stats(); stats();
debug( "sent one trash from %s\n", str_fn[t] );
svars->trash_pending[t]--; svars->trash_pending[t]--;
if (check_cancel( svars )) if (check_cancel( svars ))
return; return;
@ -1794,11 +1809,20 @@ sync_close( sync_vars_t *svars, int t )
{ {
if ((~svars->state[t] & (ST_FOUND_NEW | ST_SENT_TRASH)) || svars->trash_pending[t] || if ((~svars->state[t] & (ST_FOUND_NEW | ST_SENT_TRASH)) || svars->trash_pending[t] ||
(~svars->state[t^1] & (ST_SENT_NEW | ST_SENT_FLAGS)) || svars->new_pending[t^1] || svars->flags_pending[t^1]) (~svars->state[t^1] & (ST_SENT_NEW | ST_SENT_FLAGS)) || svars->new_pending[t^1] || svars->flags_pending[t^1])
{ debug("can't close %d, %s new, %s trash (%u pending); opposite: %s new (%u pending), %s flags (%u pending)\n",
t, svars->state[t] & ST_FOUND_NEW ? "found" : "finding",
svars->state[t] & ST_SENT_TRASH ? "sent" : "sending", svars->trash_pending[t],
svars->state[t^1] & ST_SENT_NEW ? "sent" : "sending", svars->new_pending[t^1],
svars->state[t^1] & ST_SENT_FLAGS ? "sent" : "sending", svars->flags_pending[t^1]);
return; return;
}
if (svars->state[t] & ST_CLOSING) if (svars->state[t] & ST_CLOSING)
{ debug("already closing %d\n", t);
return; return;
}
svars->state[t] |= ST_CLOSING; svars->state[t] |= ST_CLOSING;
debug("closing %d\n", t);
if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE) if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE)
&& !(svars->state[t] & ST_TRASH_BAD)) { && !(svars->state[t] & ST_TRASH_BAD)) {

Loading…
Cancel
Save