[srm-cvs] CVS Update: - Changed the connection pool structure to have one indexable record, this

From: <d.rethans[@]jdimedia.nl>
Date: Thu Feb 20 2003 - 20:06:11 CET

Date: Thu Feb 20 20:06:10 CET 2003
User: Derick Rethans
Directory: srm/main/src

Log Message:
 [0.50]
 - Changed the connection pool structure to have one indexable record, this
   is easier to pass to other functions.
 
Modified files:
           srm/main/main.c (version: 1.72)
           srm/main/src/srm_protocols.c (version: 1.8)
           srm/main/src/srm_protocols.h (version: 1.6)

[FILE: /srm/main/main.c]

--- srm/main/main.c:1.71 Wed Feb 19 19:40:26 2003 GMT
+++ srm/main/main.c Thu Feb 20 18:06:09 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.71 2003/02/19 20:40:26 derick Exp $ */
+/* $Id: cvstemp,v 1.72 2003/02/20 19:06:09 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -295,13 +295,13 @@
                 CP_SELECT(timeout);
 
                 for (fd = 0; fd <= CP.max_fd; fd++) {
- if ((CP.status[fd] == SRM_STATUS_RENDEZVOUS) && CP_ISNEWCONNECT(fd)) {
- if (CP.protocol[fd]->host.family == AF_UNIX) {
+ if ((CP.info[fd].status == SRM_STATUS_RENDEZVOUS) && CP_ISNEWCONNECT(fd)) {
+ if (CP.info[fd].protocol->host.family == AF_UNIX) {
                                         client_un_len = sizeof (client_un);
                                         new_fd = accept (fd, (struct sockaddr *) &client_un, &client_un_len);
                                         srm_fmt_message (LL_CONNECTION, "Connect", "%s", INI_SETTING(sockname));
 
- } else if (CP.protocol[fd]->host.family == AF_INET) {
+ } else if (CP.info[fd].protocol->host.family == AF_INET) {
                                         client_in_len = sizeof (client_in);
                                         new_fd = accept (fd, (struct sockaddr *) &client_in, &client_in_len);
                                         iaddr = &client_in.sin_addr;
@@ -315,12 +315,9 @@
                         }
 
                         
- if ((CP.status[fd] == SRM_STATUS_NORMAL) && CP_CONNECTION_AVAILABLE(fd)) {
+ if ((CP.info[fd].status == SRM_STATUS_NORMAL) && CP_CONNECTION_AVAILABLE(fd)) {
                                 /* srm_process_data processes all incoming packets */
- if (CP.protocol[fd]->process(fd) != SRM_SUCCESS) {
- /* When a connection gets dropped, it is removed from
- the set {FIX ME: this is now done in the processing
- code itself */
+ if (CP.info[fd].protocol->process(fd) != SRM_SUCCESS) {
                                         CP_CLOSE_CONNECTION(fd);
                                 } else {
                                         /* Do stuff too */
@@ -383,7 +380,7 @@
 
 /* Closing sockets */
         for (fd = 3; fd < CP.max_fd; fd++) {
- if (CP.status[fd] != SRM_STATUS_NOT_USED) {
+ if (CP.info[fd].status != SRM_STATUS_NOT_USED) {
                         close(fd);
                 }
         }

[FILE: /srm/main/src/srm_protocols.c]

--- srm/main/src/srm_protocols.c:1.7 Wed Feb 19 19:40:27 2003 GMT
+++ srm/main/src/srm_protocols.c Thu Feb 20 18:06:10 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.7 2003/02/19 20:40:27 derick Exp $ */
+/* $Id: cvstemp,v 1.8 2003/02/20 19:06:10 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -92,7 +92,7 @@
 void srm_close_connection (int fd)
 {
         FD_CLR((fd), &connection_pool.test_set);
- connection_pool.status[fd] = SRM_STATUS_NOT_USED;
+ connection_pool.info[fd].status = SRM_STATUS_NOT_USED;
         close(fd);
 }
 
@@ -145,8 +145,8 @@
         int i;
 
         for (i = 0; i < FD_SETSIZE; i++) {
- cp->status[i] = SRM_STATUS_NOT_USED;
- cp->protocol[i] = NULL;
+ cp->info[i].status = SRM_STATUS_NOT_USED;
+ cp->info[i].protocol = NULL;
         }
         
         FD_ZERO(&(cp->test_set));
@@ -157,8 +157,8 @@
                         srm_protocol_list[i]->host.port,
                         srm_protocol_list[i]->host.host
                 );
- cp->status[sock] = SRM_STATUS_RENDEZVOUS;
- cp->protocol[sock] = srm_protocol_list[i];
+ cp->info[sock].status = SRM_STATUS_RENDEZVOUS;
+ cp->info[sock].protocol = srm_protocol_list[i];
 
                 FD_SET(sock, &(cp->test_set));
                 if (sock > cp->max_fd) {

[FILE: /srm/main/src/srm_protocols.h]

--- srm/main/src/srm_protocols.h:1.5 Wed Feb 19 19:15:54 2003 GMT
+++ srm/main/src/srm_protocols.h Thu Feb 20 18:06:10 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.5 2003/02/19 20:15:54 derick Exp $ */
+/* $Id: cvstemp,v 1.6 2003/02/20 19:06:10 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -39,14 +39,15 @@
         connection_pool.counter++; \
         if ((fd) > (connection_pool.max_fd)) \
                 connection_pool.max_fd = fd; \
- connection_pool.status[fd] = SRM_STATUS_NORMAL; \
- connection_pool.protocol[fd] = connection_pool.protocol[pfd];
+ connection_pool.info[fd].status = SRM_STATUS_NORMAL; \
+ connection_pool.info[fd].fd_no = fd; \
+ connection_pool.info[fd].protocol = connection_pool.info[pfd].protocol;
 
 #define CP_CONNECTION_AVAILABLE(fd) \
         FD_ISSET ((fd), &connection_pool.ready_set)
 
 #define CP_CLOSE_CONNECTION(fd) FD_CLR ((fd), &connection_pool.test_set); \
- connection_pool.status[fd] = SRM_STATUS_NOT_USED; \
+ connection_pool.info[fd].status = SRM_STATUS_NOT_USED; \
         close (fd)
 
 extern struct con_pool connection_pool;
@@ -72,10 +73,15 @@
 #define SRM_STATUS_RENDEZVOUS 1
 #define SRM_STATUS_NORMAL 2
 
+typedef struct con_info {
+ srm_bool status;
+ con_def connection;
+ srm_protocol *protocol;
+ int fd_no;
+} con_info;
+
 typedef struct con_pool {
- srm_bool status[FD_SETSIZE];
- con_def connection[FD_SETSIZE];
- srm_protocol *protocol[FD_SETSIZE];
+ con_info info[FD_SETSIZE];
         srm_ui16 max_fd;
         srm_ui32 counter;
         fd_set test_set;
Received on Thu Feb 20 20:06:12 2003

This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 13:00:02 CET