summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5637e2d)
raw | patch | inline | side by side (parent: 5637e2d)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 22 Feb 2015 15:46:30 +0000 (16:46 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 22 Feb 2015 15:46:30 +0000 (16:46 +0100) |
This command sends back the server version.
src/frontend/connection.c | patch | blob | history | |
src/include/frontend/connection.h | patch | blob | history | |
src/include/frontend/proto.h | patch | blob | history |
index 64f2cb2000322dcb83557c932282e0125a797ca2..117c6ae18adab025f667fab709c3997b7b0618e6 100644 (file)
status = sdb_connection_ping(conn);
else if (conn->cmd == SDB_CONNECTION_STARTUP)
status = sdb_fe_session_start(conn);
+
else if (conn->cmd == SDB_CONNECTION_QUERY)
status = sdb_fe_query(conn);
else if (conn->cmd == SDB_CONNECTION_FETCH)
status = sdb_fe_lookup(conn);
else if (conn->cmd == SDB_CONNECTION_STORE)
status = sdb_fe_store(conn);
+
+ else if (conn->cmd == SDB_CONNECTION_SERVER_VERSION)
+ status = sdb_connection_server_version(conn);
+
else {
sdb_log(SDB_LOG_WARNING, "frontend: Ignoring invalid command %#x",
conn->cmd);
return 0;
} /* sdb_connection_ping */
+int
+sdb_connection_server_version(sdb_conn_t *conn)
+{
+ char msg[sizeof(uint32_t) + strlen(SDB_VERSION_EXTRA) + 1];
+
+ if ((! conn) || (conn->cmd != SDB_CONNECTION_SERVER_VERSION))
+ return -1;
+
+ sdb_proto_marshal_int32(msg, sizeof(msg), (uint32_t)SDB_VERSION);
+ strncpy(msg + sizeof(uint32_t), SDB_VERSION_EXTRA,
+ sizeof(msg) - sizeof(uint32_t));
+ sdb_connection_send(conn, SDB_CONNECTION_OK, (uint32_t)sizeof(msg), msg);
+ return 0;
+} /* sdb_connection_server_version */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index c4f2bc716a75de34b31e5160cecb12fcc6e19a5b..0397e508d2eeab6f5d0fc58a9d5dbadc4496ec27 100644 (file)
int
sdb_connection_ping(sdb_conn_t *conn);
+/*
+ * sdb_connection_server_version:
+ * Send back the backend server version to the connected client.
+ *
+ * Returns:
+ * - 0 on success
+ * - a negative value else
+ */
+int
+sdb_connection_server_version(sdb_conn_t *conn);
+
/*
* sdb_fe_parse:
* Parse the query text specified in 'query' of length 'len' and return a list
index 833762d76a3644a9237c19ccb9c29f9a26e36f51..ade3a7cb192eaa7fc1ccf0fa5c01c050723c69e8 100644 (file)
* A parsed expression. Only used internally.
*/
SDB_CONNECTION_EXPR,
+
+ /*
+ * Server status queries.
+ */
+
+ /*
+ * SDB_CONNECTION_SERVER_VERSION:
+ * Retrieve the server version. The server replies with SDB_CONNECTION_OK
+ * on success and the server version as an unsigned 32-bit integer,
+ * optionally followed by a string describing extra version components.
+ * The integer server version is encoded as 100000 * major + 100 * minor +
+ * patch.
+ *
+ * 0 32 64
+ * +---------------+---------------+
+ * | SERVER_VERSION| 0 |
+ * +---------------+---------------+
+ */
+ SDB_CONNECTION_SERVER_VERSION = 1000,
} sdb_conn_state_t;
#define SDB_CONN_MSGTYPE_TO_STRING(t) \