{
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
{
/*
* 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;
+ }
}
/*
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;
}
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;
}
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);
}
}
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;
}