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 * Revision History
* *
@ -30,6 +30,7 @@
typedef struct server { typedef struct server {
char *name; /* Server name/IP address*/ char *name; /* Server name/IP address*/
int port; /* Port to listen on */ int port; /* Port to listen on */
struct server *next; /* Next service protocol */ char *protocol; /* Protocol module to use */
struct server *next; /* Next server */
} SERVER; } SERVER;
#endif #endif

View File

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

View File

@ -36,6 +36,7 @@
typedef struct backend { typedef struct backend {
char *hostname; /* Server hostname */ char *hostname; /* Server hostname */
unsigned short port; /* Port on which the server listens */ 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 */ int count; /* Number of connections to the server */
} BACKEND; } BACKEND;

View File

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