]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Fixes to director-test.
authorTimo Sirainen <tss@iki.fi>
Mon, 29 Jul 2013 19:19:03 +0000 (22:19 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 29 Jul 2013 19:19:03 +0000 (22:19 +0300)
src/director/director-test.c
src/director/director-test.sh

index 62d2a9e6f510873cac4dfe839d4e1f7cde92043a..8fceb1d0fc2bdf7099562431265329bdd6cb3a76 100644 (file)
@@ -33,7 +33,7 @@
 #define IMAP_PORT 14300
 #define DIRECTOR_IN_PORT 9091
 #define DIRECTOR_OUT_PORT 9090
-#define USER_TIMEOUT_MSECS (1000*60)
+#define USER_TIMEOUT_MSECS (1000*10) /* FIXME: this should be based on director_user_expire */
 #define ADMIN_RANDOM_TIMEOUT_MSECS 500
 #define DIRECTOR_CONN_MAX_DELAY_MSECS 100
 #define DIRECTOR_DISCONNECT_TIMEOUT_SECS 10
@@ -126,7 +126,7 @@ static void client_username_check(struct imap_client *client)
                i_error("User logging into unknown host %s",
                        net_ip2addr(&local_ip));
                host = i_new(struct host, 1);
-               host->refcount++;
+               host->refcount = 1;
                host->ip = local_ip;
                host->vhost_count = 100;
                hash_table_insert(hosts, &host->ip, host);
@@ -331,12 +331,13 @@ static void director_connection_timeout(struct director_connection *conn)
 }
 
 static void
-director_connection_create(int in_fd, const struct ip_addr *local_ip)
+director_connection_create(int in_fd, const struct ip_addr *local_ip,
+                          const struct ip_addr *remote_ip)
 {
        struct director_connection *conn;
        int out_fd;
 
-       out_fd = net_connect_ip(local_ip, DIRECTOR_OUT_PORT, NULL);
+       out_fd = net_connect_ip(local_ip, DIRECTOR_OUT_PORT, remote_ip);
        if (out_fd == -1) {
                i_close_fd(&in_fd);
                return;
@@ -386,16 +387,18 @@ static void director_connection_destroy(struct director_connection **_conn)
 
 static void client_connected(struct master_service_connection *conn)
 {
-       struct ip_addr local_ip;
+       struct ip_addr local_ip, remote_ip;
        unsigned int local_port;
 
        if (net_getsockname(conn->fd, &local_ip, &local_port) < 0)
                i_fatal("net_getsockname() failed: %m");
+       if (net_getpeername(conn->fd, &remote_ip, NULL) < 0)
+               i_fatal("net_getsockname() failed: %m");
 
        if (local_port == IMAP_PORT)
                imap_client_create(conn->fd);
        else if (local_port == DIRECTOR_IN_PORT)
-               director_connection_create(conn->fd, &local_ip);
+               director_connection_create(conn->fd, &local_ip, &remote_ip);
        else {
                i_error("Connection to unknown port %u", local_port);
                return;
@@ -499,6 +502,7 @@ static void admin_read_hosts(struct admin_connection *conn)
                        struct host *host;
 
                        host = i_new(struct host, 1);
+                       host->refcount = 1;
                        if (net_addr2ip(args[0], &host->ip) < 0 ||
                            str_to_uint(args[1], &host->vhost_count) < 0)
                                i_fatal("host list broken");
@@ -542,7 +546,7 @@ static void main_init(const char *admin_path)
        admin_read_hosts(admin);
 
        to_disconnect =
-               timeout_add(1000*(1 + rand()%DIRECTOR_DISCONNECT_TIMEOUT_SECS),
+               timeout_add(1000*(5 + rand()%DIRECTOR_DISCONNECT_TIMEOUT_SECS),
                            director_connection_disconnect_timeout, (void *)NULL);
 }
 
index 5c2b4c93e98826876b4b266877d83c602e7ea621..c88794cef8c9503c311f614bc02ac3a785470007 100755 (executable)
@@ -26,6 +26,7 @@ log_path = /var/log/dovecot.log
 info_log_path = /var/log/dovecot-access.log
 director_servers =$dirs
 director_mail_servers = 127.0.0.1-127.0.0.255
+director_user_expire = 15s
 disable_plaintext_auth = no
 
 ssl = no
@@ -90,4 +91,4 @@ echo 'for conf in dovecot*.conf; do dovecot -c $conf; done'
 echo
 echo "Start testing:"
 echo
-echo "imaptest host=director user=test%d.%d - select=0 no_tracking"
+echo "imaptest host=director user=test%d.%d - select=0 no_tracking clients=1000"