Fix error message typo
authorTatsuo Ishii <ishii at sraoss.co.jp>
Wed, 19 Oct 2005 03:58:48 +0000 (03:58 +0000)
committerTatsuo Ishii <ishii at sraoss.co.jp>
Wed, 19 Oct 2005 03:58:48 +0000 (03:58 +0000)
pool_auth fails if client_min_messages is verbose. pool_auth should
processes NOTICE etc. while waiting for backendkeydata

pool_auth.c

index d5460ccb81fa656a76336c8491a825b49de7cfa2..c2dee20f06247699140f06a2e65ebd897bfbe175 100644 (file)
@@ -217,21 +217,46 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
        {
                if (protoMajor == PROTO_MAJOR_V3)
                {
-                       /* process parameter status */
-                       while (kind == 'S')
+                       do
                        {
-                               if (ParameterStatus(frontend, cp) != POOL_CONTINUE)
+                               switch(kind)
+                               {
+                                       case 'S':
+                                               /* process parameter status */
+                                               if (ParameterStatus(frontend, cp) != POOL_CONTINUE)
+                                                       return -1;
+                                               pool_flush(frontend);
+                                               break;
+
+                                       case 'N':
+                                               /* process notice message */
+                                               if (SimpleForwardToFrontend(kind, frontend, cp))
+                                                       return -1;
+                                               pool_flush(frontend);
+                                               break;
+
+                                               /* process error message */
+                                       case 'E':
+                                               SimpleForwardToFrontend(kind, frontend, cp);
+                                               pool_flush(frontend);
                                                return -1;
+                                               break;
 
-                               pool_flush(frontend);
-
+                                       default:
+                                               pool_error("pool_do_auth: unknown response \"%c\" before processing BackendKeyData",
+                                                                  kind);
+                                               return -1;
+                                               break;
+                               }
+                                               
                                kind = pool_read_kind(cp);
                                if (kind < 0)
                                {
                                        pool_error("pool_do_auth: failed to read kind while processing ParamterStatus");
                                        return -1;
                                }
-                       }
+
+                       } while (kind != 'K');
                }
                else
                {
@@ -243,10 +268,19 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
        /*
         * message length (V3 only)
         */
-       if (protoMajor == PROTO_MAJOR_V3 && (length = pool_read_message_length(cp)) != 12)
+       if (protoMajor == PROTO_MAJOR_V3)
        {
-               pool_error("pool_do_auth: invalid messages length(%d) for BackendKeyData", length);
-               return -1;
+               if (kind != 'K')
+               {
+                       pool_error("pool_do_auth: expect \"K\" got %c", kind);
+                       return -1;
+               }
+
+               if ((length = pool_read_message_length(cp)) != 12)
+               {
+                       pool_error("pool_do_auth: invalid messages length(%d) for BackendKeyData", length);
+                       return -1;
+               }
        }
 
        /*
@@ -861,26 +895,26 @@ int pool_read_message_length(POOL_CONNECTION_POOL *cp)
        status = pool_read(MASTER(cp), &length, sizeof(length));
        if (status < 0)
        {
-               pool_error("read_message_length: error while reading message length");
+               pool_error("pool_read_message_length: error while reading message length");
                return -1;
        }
        length = ntohl(length);
 
-       pool_debug("read_message_length: lenghth: %d", length);
+       pool_debug("pool_read_message_length: lenghth: %d", length);
 
        if (DUAL_MODE)
        {
                status = pool_read(SECONDARY(cp), &length1, sizeof(length1));
                if (status < 0)
                {
-                       pool_error("read_message_length: error while reading message length from secondary backend");
+                       pool_error("pool_read_message_length: error while reading message length from secondary backend");
                        return -1;
                }
                length1 = ntohl(length1);
 
                if (length != length1)
                {
-                       pool_error("read_message_length: length does not match between backends master(%d) secondary(%d)",
+                       pool_error("pool_read_message_length: length does not match between backends master(%d) secondary(%d)",
                                           length, length1);
                        return -1;
                }
@@ -888,7 +922,7 @@ int pool_read_message_length(POOL_CONNECTION_POOL *cp)
 
        if (length < 0)
        {
-               pool_error("read_message_length: invalid message length (%d)", length);
+               pool_error("pool_read_message_length: invalid message length (%d)", length);
                return -1;
        }
 
@@ -909,26 +943,26 @@ int *pool_read_message_length2(POOL_CONNECTION_POOL *cp)
        status = pool_read(MASTER(cp), &length, sizeof(length));
        if (status < 0)
        {
-               pool_error("read_message_length2: error while reading message length");
+               pool_error("pool_read_message_length2: error while reading message length");
                return NULL;
        }
        length = ntohl(length);
 
-       pool_debug("read_message_length2: master lenghth: %d", length);
+       pool_debug("pool_read_message_length2: master lenghth: %d", length);
 
        if (DUAL_MODE)
        {
                status = pool_read(SECONDARY(cp), &length1, sizeof(length1));
                if (status < 0)
                {
-                       pool_error("read_message_length2: error while reading message length from secondary backend");
+                       pool_error("pool_read_message_length2: error while reading message length from secondary backend");
                        return NULL;
                }
                length1 = ntohl(length1);
 
                if (length != length1)
                {
-                       pool_debug("read_message_length2: length does not match between backends master(%d) secondary(%d)",
+                       pool_debug("pool_read_message_length2: length does not match between backends master(%d) secondary(%d)",
                                           length, length1);
                }
        }
@@ -939,7 +973,7 @@ int *pool_read_message_length2(POOL_CONNECTION_POOL *cp)
 
        if (length < 0 || length1 < 0)
        {
-               pool_error("read_message_length2: invalid message length (%d) length1 (%d)", length, length1);
+               pool_error("pool_read_message_length2: invalid message length (%d) length1 (%d)", length, length1);
                return NULL;
        }