summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-03-11 03:48:54 +0100
committerGitHub <noreply@github.com>2019-03-11 03:48:54 +0100
commit23b515f67f912078268767ec2d28b65711d39b2f (patch)
treeca7ef86914fd19a7fba137feb8daf668d6411b63 /src/common
parentc2bf96805ea5fdbd8d88bb1ddaf9f0e47a24fd08 (diff)
parent63062f9ddbc2c2a2384bfbbd496fc0572318a9e0 (diff)
downloadhercules-23b515f67f912078268767ec2d28b65711d39b2f.tar.gz
hercules-23b515f67f912078268767ec2d28b65711d39b2f.tar.bz2
hercules-23b515f67f912078268767ec2d28b65711d39b2f.tar.xz
hercules-23b515f67f912078268767ec2d28b65711d39b2f.zip
Merge pull request #2378 from 4144/interfaces
Different interfaces fixes
Diffstat (limited to 'src/common')
-rw-r--r--src/common/socket.c13
-rw-r--r--src/common/socket.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 95d8bf578..faf57f412 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -79,8 +79,6 @@
static struct socket_interface sockt_s;
struct socket_interface *sockt;
-static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf";
-
#ifdef SEND_SHORTLIST
// Add a fd to the shortlist so that it'll be recognized as a fd that needs
// sending done on it.
@@ -462,7 +460,7 @@ static int recv_to_fifo(int fd)
socket_data_ci += len;
}
#endif // SHOW_SERVER_STATS
- return 0;
+ return (int)len;
}
static int send_from_fifo(int fd)
@@ -648,7 +646,7 @@ static int make_listen_bind(uint32 ip, uint16 port)
if(sockt->fd_max <= fd) sockt->fd_max = fd + 1;
- create_session(fd, connect_client, null_send, null_parse);
+ create_session(fd, sockt->connect_client, null_send, null_parse);
sockt->session[fd]->client_addr = 0; // just listens
sockt->session[fd]->rdata_tick = 0; // disable timeouts on this socket
return fd;
@@ -1505,7 +1503,7 @@ static bool socket_config_read(const char *filename, bool imported)
// import should overwrite any previous configuration, so it should be called last
if (libconfig->lookup_string(&config, "import", &import) == CONFIG_TRUE) {
- if (strcmp(import, filename) == 0 || strcmp(import, SOCKET_CONF_FILENAME) == 0) {
+ if (strcmp(import, filename) == 0 || strcmp(import, sockt->SOCKET_CONF_FILENAME) == 0) {
ShowWarning("socket_config_read: Loop detected! Skipping 'import'...\n");
} else {
if (!socket_config_read(import, true))
@@ -1714,7 +1712,7 @@ static void socket_init(void)
// Get initial local ips
sockt->naddr_ = sockt->getips(sockt->addr_,16);
- socket_config_read(SOCKET_CONF_FILENAME, false);
+ socket_config_read(sockt->SOCKET_CONF_FILENAME, false);
#ifndef SOCKET_EPOLL
// Select based Event Dispatcher:
@@ -2143,6 +2141,8 @@ void socket_defaults(void)
{
sockt = &sockt_s;
+ sockt->SOCKET_CONF_FILENAME = "conf/common/socket.conf";
+
sockt->fd_max = 0;
/* */
sockt->stall_time = 60;
@@ -2177,6 +2177,7 @@ void socket_defaults(void)
/* */
sockt->flush = flush_fifo;
sockt->flush_fifos = flush_fifos;
+ sockt->connect_client = connect_client;
sockt->set_nonblocking = set_nonblocking;
sockt->set_defaultparse = set_defaultparse;
sockt->host2ip = host2ip;
diff --git a/src/common/socket.h b/src/common/socket.h
index 5e4251989..193b22645 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -178,6 +178,7 @@ struct socket_interface {
time_t stall_time;
time_t last_tick;
+ const char *SOCKET_CONF_FILENAME;
/* */
uint32 addr_[16]; // ip addresses of local host (host byte order)
int naddr_; // # of ip addresses
@@ -212,6 +213,7 @@ struct socket_interface {
/* */
void (*flush) (int fd);
void (*flush_fifos) (void);
+ int (*connect_client) (int listen_fd);
void (*set_nonblocking) (int fd, unsigned long yes);
void (*set_defaultparse) (ParseFunc defaultparse);
/* hostname/ip conversion functions */