summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-08-04 12:19:25 -0300
committershennetsind <ind@henn.et>2013-08-08 15:07:40 -0300
commit6b9f58446c46877ecfc5fe40847636145acf5af8 (patch)
tree81b71aa95a47e611a5415528cf72efefe0d552b1 /src/common/socket.c
parentdefac0ef9714121a872ab48c3f6c4ddd177ae509 (diff)
downloadhercules-6b9f58446c46877ecfc5fe40847636145acf5af8.tar.gz
hercules-6b9f58446c46877ecfc5fe40847636145acf5af8.tar.bz2
hercules-6b9f58446c46877ecfc5fe40847636145acf5af8.tar.xz
hercules-6b9f58446c46877ecfc5fe40847636145acf5af8.zip
HPM Update
- Custom Packet Support - Custom Data Struct Support (currently append-able to map_session_data and socket_data) - Char Server Support - Login Server Support http://hercules.ws/board/topic/1934-hercules-plugin-manager-update/ Documentation will soon be updated in http://hercules.ws/wiki/HPM Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index f6d5849be..4f2e386ec 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -9,6 +9,7 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../config/core.h"
+#include "../common/HPM.h"
#include "socket.h"
#include <stdio.h>
@@ -239,8 +240,6 @@ static time_t socket_data_last_tick = 0;
// The connection is closed if it goes over the limit.
#define WFIFO_MAX (1*1024*1024)
-struct socket_data* session[FD_SETSIZE];
-
#ifdef SEND_SHORTLIST
int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that
int send_shortlist_count = 0;// how many fd's are in the shortlist
@@ -594,13 +593,15 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF
session[fd]->func_parse = func_parse;
session[fd]->rdata_tick = last_tick;
session[fd]->session_data = NULL;
+ session[fd]->hdata = NULL;
+ session[fd]->hdatac = 0;
return 0;
}
static void delete_session(int fd)
{
- if( session_isValid(fd) )
- {
+ if( session_isValid(fd) ) {
+ unsigned int i;
#ifdef SHOW_SERVER_STATS
socket_data_qi -= session[fd]->rdata_size - session[fd]->rdata_pos;
socket_data_qo -= session[fd]->wdata_size;
@@ -609,6 +610,14 @@ static void delete_session(int fd)
aFree(session[fd]->wdata);
if( session[fd]->session_data )
aFree(session[fd]->session_data);
+ for(i = 0; i < session[fd]->hdatac; i++) {
+ if( session[fd]->hdata[i]->flag.free ) {
+ aFree(session[fd]->hdata[i]->data);
+ aFree(session[fd]->hdata[i]);
+ }
+ }
+ if( session[fd]->hdata )
+ aFree(session[fd]->hdata);
aFree(session[fd]);
session[fd] = NULL;
}
@@ -1214,6 +1223,8 @@ void socket_final(void)
aFree(session[0]->rdata);
aFree(session[0]->wdata);
aFree(session[0]);
+
+ aFree(session);
}
/// Closes a socket.
@@ -1375,6 +1386,8 @@ void socket_init(void)
memset(send_shortlist_set, 0, sizeof(send_shortlist_set));
#endif
+ CREATE(session, struct socket_data *, FD_SETSIZE);
+
socket_config_read(SOCKET_CONF_FILENAME);
// initialise last send-receive tick
@@ -1392,6 +1405,11 @@ void socket_init(void)
#endif
ShowInfo("Server supports up to '"CL_WHITE"%u"CL_RESET"' concurrent connections.\n", rlim_cur);
+
+ /* Hercules Plugin Manager */
+ HPM->share(session,"session");
+ HPM->share(&fd_max,"fd_max");
+ HPM->share(addr_,"addr");
}
bool session_isValid(int fd)