]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master, anvil: [DIS]CONNECT - Move conn-guid to being the first parameter
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 17 Jan 2022 22:31:40 +0000 (23:31 +0100)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Feb 2022 09:48:24 +0000 (10:48 +0100)
It uniquely identifies the connection, so it's clearer that it's the first
parameter.

src/anvil/anvil-connection.c
src/lib-master/master-service.c

index cc1c932f2062b9e903d854f7ea9f5f3bea9bb88e..0ad686f96680bf23869380abd3f80b190ac60689 100644 (file)
@@ -80,6 +80,11 @@ anvil_connection_request(struct anvil_connection *conn,
                        *error_r = "CONNECT: Not enough parameters";
                        return -1;
                }
+               if (guid_128_from_string(args[0], conn_guid) < 0) {
+                       *error_r = "CONNECT: Invalid conn-guid";
+                       return -1;
+               }
+               args++;
                if (str_to_pid(args[0], &pid) < 0) {
                        *error_r = "CONNECT: Invalid pid";
                        return -1;
@@ -89,20 +94,17 @@ anvil_connection_request(struct anvil_connection *conn,
                        *error_r = "CONNECT: Invalid ident string";
                        return -1;
                }
-               if (args[0] == NULL) {
-                       *error_r = "CONNECT: Missing conn-guid";
-                       return -1;
-               }
-               if (guid_128_from_string(args[0], conn_guid) < 0) {
-                       *error_r = "CONNECT: Invalid conn-guid";
-                       return -1;
-               }
                connect_limit_connect(connect_limit, pid, &key, conn_guid);
        } else if (strcmp(cmd, "DISCONNECT") == 0) {
                if (args[0] == NULL || args[1] == NULL) {
                        *error_r = "DISCONNECT: Not enough parameters";
                        return -1;
                }
+               if (guid_128_from_string(args[0], conn_guid) < 0) {
+                       *error_r = "DISCONNECT: Invalid conn-guid";
+                       return -1;
+               }
+               args++;
                if (str_to_pid(args[0], &pid) < 0) {
                        *error_r = "DISCONNECT: Invalid pid";
                        return -1;
@@ -112,14 +114,6 @@ anvil_connection_request(struct anvil_connection *conn,
                        *error_r = "DISCONNECT: Invalid ident string";
                        return -1;
                }
-               if (args[0] == NULL) {
-                       *error_r = "DISCONNECT: Missing conn-guid";
-                       return -1;
-               }
-               if (guid_128_from_string(args[0], conn_guid) < 0) {
-                       *error_r = "DISCONNECT: Invalid conn-guid";
-                       return -1;
-               }
                connect_limit_disconnect(connect_limit, pid, &key, conn_guid);
        } else if (strcmp(cmd, "CONNECT-DUMP") == 0) {
                connect_limit_dump(connect_limit, conn->output);
index 2baa1783df6c6cd13a5b819717ed8f3afac139f8..4ef196298cb154822ff772a4eafe6265e1377677 100644 (file)
@@ -968,9 +968,9 @@ bool master_service_anvil_connect(struct master_service *service,
 
        string_t *cmd = t_str_new(128);
        str_append(cmd, "CONNECT\t");
-       master_service_anvil_session_to_cmd(cmd, session);
-       str_append_c(cmd, '\t');
        str_append(cmd, guid_128_to_string(conn_guid_r));
+       str_append_c(cmd, '\t');
+       master_service_anvil_session_to_cmd(cmd, session);
        str_append_c(cmd, '\n');
        return master_service_anvil_send(service, str_c(cmd));
 }
@@ -981,9 +981,9 @@ void master_service_anvil_disconnect(struct master_service *service,
 {
        string_t *cmd = t_str_new(128);
        str_append(cmd, "DISCONNECT\t");
-       master_service_anvil_session_to_cmd(cmd, session);
-       str_append_c(cmd, '\t');
        str_append(cmd, guid_128_to_string(conn_guid));
+       str_append_c(cmd, '\t');
+       master_service_anvil_session_to_cmd(cmd, session);
        str_append_c(cmd, '\n');
        (void)master_service_anvil_send(service, str_c(cmd));
 }