extern void pool_send_frontend_exits(POOL_CONNECTION_POOL *backend);
extern int pool_read_message_length(POOL_CONNECTION_POOL *cp);
+extern int *pool_read_message_length2(POOL_CONNECTION_POOL *cp);
extern signed char pool_read_kind(POOL_CONNECTION_POOL *cp);
extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
return length;
}
+/*
+ * read message length2 (V3 only)
+ * unlike pool_read_message_length, this returns an array of message length.
+ * the array is in the static storage, thus it will be destroyed by subsequent calls.
+ */
+int *pool_read_message_length2(POOL_CONNECTION_POOL *cp)
+{
+ int status;
+ int length, length1;
+ static int length_array[MAX_CONNECTION_SLOTS];
+
+ status = pool_read(MASTER(cp), &length, sizeof(length));
+ if (status < 0)
+ {
+ pool_error("read_message_length2: error while reading message length");
+ return NULL;
+ }
+ length = ntohl(length);
+
+ pool_debug("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");
+ return NULL;
+ }
+ length1 = ntohl(length1);
+
+ if (length != length1)
+ {
+ pool_debug("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);
+ return NULL;
+ }
+
+ length_array[0] = length;
+ length_array[1] = length1;
+ return &length_array[0];
+}
+
signed char pool_read_kind(POOL_CONNECTION_POOL *cp)
{
int status;
POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
int len;
+ int *len_array;
int sendlen;
char *p;
char *name;
pool_write(frontend, "S", 1);
- len = pool_read_message_length(backend);
- if (len < 0)
+ len_array = pool_read_message_length2(backend);
+
+ if (len_array == NULL)
{
return POOL_END;
}
+ len = len_array[0];
sendlen = htonl(len);
pool_write(frontend, &sendlen, sizeof(sendlen));
#endif
if (DUAL_MODE)
- if (pool_read2(SECONDARY(backend), len) == NULL)
+ if (pool_read2(SECONDARY(backend), len_array[1]-4) == NULL)
return POOL_END;
return pool_write(frontend, p, len);