Browse Source

move orig_name out of store_t

it's state specific to the synchronizer.
wip/server-refactor
Oswald Buddenhagen 10 years ago
parent
commit
85fd5ceb54
  1. 1
      src/driver.h
  2. 15
      src/sync.c

1
src/driver.h

@ -86,7 +86,6 @@ typedef struct store {
void *bad_callback_aux; void *bad_callback_aux;
/* currently open mailbox */ /* currently open mailbox */
const char *orig_name; /* foreign! maybe preset? */
char *path; /* own */ char *path; /* own */
message_t *msgs; /* own */ message_t *msgs; /* own */
int uidvalidity; int uidvalidity;

15
src/sync.c

@ -153,6 +153,7 @@ typedef struct {
channel_conf_t *chan; channel_conf_t *chan;
store_t *ctx[2]; store_t *ctx[2];
driver_t *drv[2]; driver_t *drv[2];
const char *orig_name[2];
int state[2], ref_count, nsrecs, ret, lfd; int state[2], ref_count, nsrecs, ret, lfd;
int new_total[2], new_done[2]; int new_total[2], new_done[2];
int flags_total[2], flags_done[2]; int flags_total[2], flags_done[2];
@ -599,13 +600,13 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
svars->srecadd = &svars->srecs; svars->srecadd = &svars->srecs;
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
ctx[t]->orig_name = svars->orig_name[t] =
(!names[t] || (ctx[t]->conf->map_inbox && !strcmp( ctx[t]->conf->map_inbox, names[t] ))) ? (!names[t] || (ctx[t]->conf->map_inbox && !strcmp( ctx[t]->conf->map_inbox, names[t] ))) ?
"INBOX" : names[t]; "INBOX" : names[t];
if (!ctx[t]->conf->flat_delim) { if (!ctx[t]->conf->flat_delim) {
svars->box_name[t] = nfstrdup( ctx[t]->orig_name ); svars->box_name[t] = nfstrdup( svars->orig_name[t] );
} else if (map_name( ctx[t]->orig_name, &svars->box_name[t], 0, "/", ctx[t]->conf->flat_delim ) < 0) { } else if (map_name( svars->orig_name[t], &svars->box_name[t], 0, "/", ctx[t]->conf->flat_delim ) < 0) {
error( "Error: canonical mailbox name '%s' contains flattened hierarchy delimiter\n", ctx[t]->orig_name ); error( "Error: canonical mailbox name '%s' contains flattened hierarchy delimiter\n", svars->orig_name[t] );
svars->ret = SYNC_FAIL; svars->ret = SYNC_FAIL;
sync_bail3( svars ); sync_bail3( svars );
return; return;
@ -618,7 +619,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
* don't run into uninitialized variables. */ * don't run into uninitialized variables. */
sync_ref( svars ); sync_ref( svars );
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
info( "Selecting %s %s...\n", str_ms[t], ctx[t]->orig_name ); info( "Selecting %s %s...\n", str_ms[t], svars->orig_name[t] );
svars->drv[t]->select( ctx[t], svars->box_name[t], (chan->ops[t] & OP_CREATE) != 0, box_selected, AUX ); svars->drv[t]->select( ctx[t], svars->box_name[t], (chan->ops[t] & OP_CREATE) != 0, box_selected, AUX );
if (check_cancel( svars )) if (check_cancel( svars ))
break; break;
@ -703,7 +704,7 @@ box_selected( int sts, void *aux )
} }
if (fcntl( svars->lfd, F_SETLK, &lck )) { if (fcntl( svars->lfd, F_SETLK, &lck )) {
error( "Error: channel :%s:%s-:%s:%s is locked\n", error( "Error: channel :%s:%s-:%s:%s is locked\n",
chan->stores[M]->name, ctx[M]->orig_name, chan->stores[S]->name, ctx[S]->orig_name ); chan->stores[M]->name, svars->orig_name[M], chan->stores[S]->name, svars->orig_name[S] );
svars->ret = SYNC_FAIL; svars->ret = SYNC_FAIL;
sync_bail1( svars ); sync_bail1( svars );
return; return;
@ -1403,7 +1404,7 @@ box_loaded( int sts, void *aux )
if (svars->chan->expire_unread < 0 && (unsigned)alive * 2 > svars->chan->max_messages) { if (svars->chan->expire_unread < 0 && (unsigned)alive * 2 > svars->chan->max_messages) {
error( "%s: %d unread messages in excess of MaxMessages (%d).\n" error( "%s: %d unread messages in excess of MaxMessages (%d).\n"
"Please set ExpireUnread to decide outcome. Skipping mailbox.\n", "Please set ExpireUnread to decide outcome. Skipping mailbox.\n",
svars->ctx[S]->orig_name, alive, svars->chan->max_messages ); svars->orig_name[S], alive, svars->chan->max_messages );
svars->ret |= SYNC_FAIL; svars->ret |= SYNC_FAIL;
cancel_sync( svars ); cancel_sync( svars );
return; return;

Loading…
Cancel
Save