A slight rejig of the server/service setup for the backend databases. Also including the protocol

module names.
This commit is contained in:
Mark Riddoch 2013-06-14 17:05:00 +02:00
parent 2260bf7587
commit cf6b18a4fe
4 changed files with 13 additions and 12 deletions

View File

@ -19,7 +19,7 @@
*/
/*
* The servER level definitions within the gateway
* The server level definitions within the gateway
*
* Revision History
*
@ -30,6 +30,7 @@
typedef struct server {
char *name; /* Server name/IP address*/
int port; /* Port to listen on */
struct server *next; /* Next service protocol */
char *protocol; /* Protocol module to use */
struct server *next; /* Next server */
} SERVER;
#endif

View File

@ -31,22 +31,20 @@ struct server;
struct router;
typedef struct servprotocol {
char *protocol; /* Protocol name */
int port; /* Port to listen on */
char *routerModule; /* Name of router module to use */
struct router *router;
char *protocol; /* Protocol module to load */
short port; /* Port to listen on */
struct servprotocol
*next; /* Next service protocol */
} SERV_PROTOCOL;
typedef struct service {
char *name; /* The service name */
SERV_PROTOCOL *ports; /* Linked list of ports and protocols
SERV_PROTOCOL *servers; /* Linked list of ports and protocols
* that this service will listen on.
*/
struct server *servers; /* Linked list of databases associated
* with this service
*/
char *routerModule; /* Name of router module to use */
struct router *router; /* The router we are using */
struct server *databases; /* The set of servers in the backend */
} SERVICE;
#endif

View File

@ -36,6 +36,7 @@
typedef struct backend {
char *hostname; /* Server hostname */
unsigned short port; /* Port on which the server listens */
char *protocol; /* Protocol to use to connect to the server */
int count; /* Number of connections to the server */
} BACKEND;

View File

@ -124,7 +124,7 @@ int i, n;
* that we can maintain a count of the number of connections to each
* backend server.
*/
for (server = service->servers, n = 0; server; server = server->next)
for (server = service->databases, n = 0; server; server = server->next)
n++;
inst->servers = (BACKEND **)calloc(n, sizeof(BACKEND *));
@ -134,7 +134,7 @@ int i, n;
return NULL;
}
for (server = service->servers, n = 0; server; server = server->next)
for (server = service->databases, n = 0; server; server = server->next)
{
if ((inst->servers[n] = malloc(sizeof(BACKEND))) == NULL)
{
@ -145,6 +145,7 @@ int i, n;
return;
}
inst->servers[n]->hostname = strdup(server->name);
inst->servers[n]->protocol = strdup(server->protocol);
inst->servers[n]->port = server->port;
inst->servers[n]->count = 0;
n++;