From 0a612a0a5a567605483b6401cbe0a2f7ee9133dc Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 8 Feb 2007 01:33:40 +0000 Subject: * More aggressive cleaning up of the socket code - removed unused session_data2 entry in sd - added a new create_session() function, helps keep things cleaner (although it's ad-hoc and not perfect, since this is C) - undid r4978 since it was getting in the way (re-add it if you need it) - added defines for the recv, send and parse func pointers - added null functions for the three actions, and made create_session() calls use those instead of NULL pointers; insignificant penalty and now: - since all three funcs are always initialized, removed all those NULL checks - removed the efd set, since as the people from the developernet forums pointed out, it's only for out-of-band data and NOT for error checking (in fact, select() bails out without giving any info if it errors out) - reorganized the randomly placed socket.c contents somewhat git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9822 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/common/socket.h') diff --git a/src/common/socket.h b/src/common/socket.h index 7a07a3770..dc156318c 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -14,6 +14,7 @@ #endif #include "../common/cbasetypes.h" +#include // define declaration @@ -70,6 +71,9 @@ // Struct declaration +typedef int (*RecvFunc)(int fd); +typedef int (*SendFunc)(int fd); +typedef int (*ParseFunc)(int fd); struct socket_data { unsigned char eof; @@ -79,11 +83,10 @@ struct socket_data { size_t rdata_pos; time_t rdata_tick; struct sockaddr_in client_addr; - int (*func_recv)(int); - int (*func_send)(int); - int (*func_parse)(int); void* session_data; - void* session_data2; + RecvFunc func_recv; + SendFunc func_send; + ParseFunc func_parse; }; @@ -107,7 +110,7 @@ extern int session_isActive(int fd); int make_listen_port(int); int make_listen_bind(long,int); int make_connection(long,int); -int delete_session(int); +int delete_session(int fd); int realloc_fifo(int fd,unsigned int rfifo_size,unsigned int wfifo_size); int realloc_writefifo(int fd, size_t addition); int WFIFOSET(int fd,int len); -- cgit v1.2.3-60-g2f50