Mercurial > dovecot > core-2.2
comparison src/director/director.c @ 22572:4a0792a03f5a
director: Allow doveadm director ring remove for the same director
Fixes:
Panic: file doveadm-connection.c: line 859 (doveadm_connection_cmd_run): assertion failed: (conn->dir->right == NULL && conn->dir->left == NULL)
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 05 Oct 2017 11:51:23 +0300 |
parents | 98b21e27d66c |
children | 0813fee4d105 |
comparison
equal
deleted
inserted
replaced
22571:4057b92ed502 | 22572:4a0792a03f5a |
---|---|
533 const char *cmd; | 533 const char *cmd; |
534 | 534 |
535 i_info("Removing director %s from ring (requested by %s)", | 535 i_info("Removing director %s from ring (requested by %s)", |
536 removed_host->name, src->name); | 536 removed_host->name, src->name); |
537 | 537 |
538 if (removed_host->self) { | 538 if (removed_host->self && !src->self) { |
539 /* others will just disconnect us */ | 539 /* others will just disconnect us */ |
540 return; | 540 return; |
541 } | 541 } |
542 | 542 |
543 /* mark the host as removed and fully remove it later. this delay is | 543 if (!removed_host->self) { |
544 needed, because the removal may trigger director reconnections, | 544 /* mark the host as removed and fully remove it later. this |
545 which may send the director back and we don't want to re-add it */ | 545 delay is needed, because the removal may trigger director |
546 removed_host->removed = TRUE; | 546 reconnections, which may send the director back and we don't |
547 if (dir->to_remove_dirs == NULL) { | 547 want to re-add it */ |
548 dir->to_remove_dirs = | 548 removed_host->removed = TRUE; |
549 timeout_add(DIRECTOR_DELAYED_DIR_REMOVE_MSECS, | 549 if (dir->to_remove_dirs == NULL) { |
550 director_delayed_dir_remove_timeout, dir); | 550 dir->to_remove_dirs = |
551 timeout_add(DIRECTOR_DELAYED_DIR_REMOVE_MSECS, | |
552 director_delayed_dir_remove_timeout, dir); | |
553 } | |
551 } | 554 } |
552 | 555 |
553 /* if our left or ride side gets removed, notify them first | 556 /* if our left or ride side gets removed, notify them first |
554 before disconnecting. */ | 557 before disconnecting. */ |
555 cmd = t_strdup_printf("DIRECTOR-REMOVE\t%s\t%u\n", | 558 cmd = t_strdup_printf("DIRECTOR-REMOVE\t%s\t%u\n", |
560 | 563 |
561 /* disconnect any connections to the host */ | 564 /* disconnect any connections to the host */ |
562 conns = array_get(&dir->connections, &count); | 565 conns = array_get(&dir->connections, &count); |
563 for (i = 0; i < count; ) { | 566 for (i = 0; i < count; ) { |
564 conn = conns[i]; | 567 conn = conns[i]; |
565 if (director_connection_get_host(conn) != removed_host) | 568 if (director_connection_get_host(conn) != removed_host || |
569 removed_host->self) | |
566 i++; | 570 i++; |
567 else { | 571 else { |
568 director_connection_deinit(&conn, "Removing from ring"); | 572 director_connection_deinit(&conn, "Removing from ring"); |
569 conns = array_get(&dir->connections, &count); | 573 conns = array_get(&dir->connections, &count); |
570 } | 574 } |