From cf6b18a4fe00a2530f73af1a20865586962ac991 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Fri, 14 Jun 2013 17:05:00 +0200 Subject: [PATCH] A slight rejig of the server/service setup for the backend databases. Also including the protocol module names. --- include/server.h | 5 +++-- include/service.h | 14 ++++++-------- modules/include/readconnection.h | 1 + modules/routing/readconnroute.c | 5 +++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/server.h b/include/server.h index 9dc7b4254..e2dfdeaad 100644 --- a/include/server.h +++ b/include/server.h @@ -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 diff --git a/include/service.h b/include/service.h index a616cdcc6..527f6d90e 100644 --- a/include/service.h +++ b/include/service.h @@ -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 diff --git a/modules/include/readconnection.h b/modules/include/readconnection.h index bc97f11ad..1c686c71b 100644 --- a/modules/include/readconnection.h +++ b/modules/include/readconnection.h @@ -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; diff --git a/modules/routing/readconnroute.c b/modules/routing/readconnroute.c index 79e389e75..6076e1c9a 100644 --- a/modules/routing/readconnroute.c +++ b/modules/routing/readconnroute.c @@ -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++;