]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: test-smtp-server-errors - Fix "many bad commands" test.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 25 May 2020 15:16:30 +0000 (17:16 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 25 May 2020 15:29:02 +0000 (17:29 +0200)
It didn't properly handle the two parallel connections. Removed a useless
context struct definition. Modified debug message for easier debugging.

src/lib-smtp/test-smtp-server-errors.c

index 86023381b037dd8090d41b1d9f6c37fc7aa5d46d..ce4e34873ced45a8147c94277c5884d195212b3e 100644 (file)
@@ -582,7 +582,7 @@ test_many_bad_commands_client_input(struct client_connection *conn)
        while ((ret=smtp_reply_parse_next(ctx->parser, FALSE,
                                          &reply, &error)) > 0) {
                if (debug)
-                       i_debug("REPLY: %s", smtp_reply_log(reply));
+                       i_debug("REPLY #%u: %s", ctx->reply, smtp_reply_log(reply));
 
                switch (ctx->reply++) {
                /* greeting */
@@ -651,20 +651,20 @@ static void test_client_many_bad_commands(unsigned int index)
 
 /* server */
 
-struct _many_bad_commands {
-       struct istream *payload_input;
-       struct io *io;
-
-       bool serviced:1;
-};
-
 static void
 test_server_many_bad_commands_disconnect(void *context ATTR_UNUSED,
-                                          const char *reason)
+                                        const char *reason)
 {
+       struct server_connection *sconn = context;
+
        if (debug)
                i_debug("Disconnect: %s", reason);
-       io_loop_stop(ioloop);
+
+       sconn->context = POINTER_CAST(POINTER_CAST_TO(sconn->context,
+                                                     unsigned int) + 1);
+
+       if (POINTER_CAST_TO(sconn->context, unsigned int) == 2)
+               io_loop_stop(ioloop);
 }
 
 static int