viewing paste Unknown #6536 | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/common/socket.c b/src/common/socket.c
index f6d5849befad85bfc6de98827e4cb562725fd82f..7181c7703a09057b818ce97ccf91c479476b4d4a 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -239,7 +239,7 @@ char* sErr(int code)
 // The connection is closed if it goes over the limit.
 #define WFIFO_MAX (1*1024*1024)
 
-struct socket_data* session[FD_SETSIZE];
+struct socket_data **session;
 
 #ifdef SEND_SHORTLIST
 int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that
@@ -1214,6 +1214,8 @@ void socket_final(void)
    aFree(session[0]->rdata);
    aFree(session[0]->wdata);
    aFree(session[0]);
+   
+   aFree(session);
 }
 
 /// Closes a socket.
@@ -1375,6 +1377,9 @@ void socket_init(void)
    memset(send_shortlist_set, 0, sizeof(send_shortlist_set));
 #endif
 
+   CREATE(session, struct socket_data *, FD_SETSIZE);
+   memset(session, 0, sizeof(struct socket_data *) * FD_SETSIZE);
+   
    socket_config_read(SOCKET_CONF_FILENAME);
 
    // initialise last send-receive tick
diff --git a/src/common/socket.h b/src/common/socket.h
index 82f8b84c3f485cb6fe28d04b9c910b45c73bbfcb..8dbddea8cc9732c32d16b19ba2d21c8a401e0b19 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -105,7 +105,7 @@ struct hSockOpt {
 
 // Data prototype declaration
 
-extern struct socket_data* session[FD_SETSIZE];
+extern struct socket_data **session;
 
 extern int fd_max;
 
 
Viewed 995 times, submitted by Guest.