From e918e4d9a8a56cc6a0a653fa6398d731484496c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 21 Mar 2019 03:20:26 +0300 Subject: Add ZC_PING and CZ_PING packets For supported packet version, from now server send ping packets to client. --- src/common/socket.c | 7 +++++-- src/common/socket.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/socket.c b/src/common/socket.c index faf57f412..dc5b06da0 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -488,11 +488,12 @@ static int send_from_fifo(int fd) return 0; } - if( len > 0 ) + if (len > 0) { + sockt->session[fd]->wdata_tick = sockt->last_tick; // some data could not be transferred? // shift unsent data to the beginning of the queue - if( (size_t)len < sockt->session[fd]->wdata_size ) + if ((size_t)len < sockt->session[fd]->wdata_size) memmove(sockt->session[fd]->wdata, sockt->session[fd]->wdata + len, sockt->session[fd]->wdata_size - len); sockt->session[fd]->wdata_size -= len; @@ -649,6 +650,7 @@ static int make_listen_bind(uint32 ip, uint16 port) 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 + sockt->session[fd]->wdata_tick = 0; return fd; } @@ -731,6 +733,7 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF sockt->session[fd]->func_send = func_send; sockt->session[fd]->func_parse = func_parse; sockt->session[fd]->rdata_tick = sockt->last_tick; + sockt->session[fd]->wdata_tick = sockt->last_tick; sockt->session[fd]->session_data = NULL; sockt->session[fd]->hdata = NULL; return 0; diff --git a/src/common/socket.h b/src/common/socket.h index 193b22645..b20b0b07e 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -130,6 +130,7 @@ struct socket_data { size_t rdata_pos; uint32 last_head_size; time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled + time_t wdata_tick; // time of last send (for detecting timeouts); RecvFunc func_recv; SendFunc func_send; -- cgit v1.2.3-70-g09d2