Addition of argument types to the debug cli

Added commands to settign and clearign status bits in the servers
This commit is contained in:
Mark Riddoch
2013-06-25 20:15:57 +02:00
parent 66c130d8a4
commit 3338e9cdb0
3 changed files with 190 additions and 25 deletions

View File

@ -59,7 +59,7 @@ SERVER *server;
server->protocol = strdup(protocol);
server->port = port;
memset(&server->stats, sizeof(SERVER_STATS), 0);
server->status = 0;
server->status = SERVER_RUNNING;
server->nextdb = NULL;
spinlock_acquire(&server_spin);
@ -159,6 +159,7 @@ SERVER *ptr;
{
dcb_printf(dcb, "Server %p\n", ptr);
dcb_printf(dcb, "\tServer: %s\n", ptr->name);
dcb_printf(dcb, "\tStatus: %s\n", server_status(ptr));
dcb_printf(dcb, "\tProtocol: %s\n", ptr->protocol);
dcb_printf(dcb, "\tPort: %d\n", ptr->port);
dcb_printf(dcb, "\tNumber of connections: %d\n", ptr->stats.n_connections);
@ -167,6 +168,23 @@ SERVER *ptr;
spinlock_release(&server_spin);
}
/**
* Print server details to a DCB
*
* Designed to be called within a debugger session in order
* to display all active servers within the gateway
*/
void
dprintServer(DCB *dcb, SERVER *server)
{
dcb_printf(dcb, "Server %p\n", server);
dcb_printf(dcb, "\tServer: %s\n", server->name);
dcb_printf(dcb, "\tStatus: %s\n", server_status(server));
dcb_printf(dcb, "\tProtocol: %s\n", server->protocol);
dcb_printf(dcb, "\tPort: %d\n", server->port);
dcb_printf(dcb, "\tNumber of connections: %d\n", server->stats.n_connections);
}
/**
* Convert a set of server status flags to a string, the returned
* string has been malloc'd and must be free'd by the caller
@ -192,3 +210,27 @@ char *status = NULL;
strcat(status, "Slave");
return status;
}
/**
* Set a status bit in the server
*
* @param server The server to update
* @param bit The bit to set for the server
*/
void
server_set_status(SERVER *server, int bit)
{
server->status |= bit;
}
/**
* Clear a status bit in the server
*
* @param server The server to update
* @param bit The bit to clear for the server
*/
void
server_clear_status(SERVER *server, int bit)
{
server->status &= ~bit;
}