Merge 88be6cfb22fe8bc34727937f465fa88fd60730e3 into 78bcc0a2cfb33ec940bfb14cb12ea10efa3af93a
This commit is contained in:
commit
5e64d8b55e
@ -35,6 +35,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "ae.h"
|
||||
|
||||
@ -150,6 +151,15 @@ struct connListener {
|
||||
void *priv; /* used by connection type specified data */
|
||||
};
|
||||
|
||||
/* anet-style wrappers to conns */
|
||||
int connBlock(connection *conn);
|
||||
int connNonBlock(connection *conn);
|
||||
int connEnableTcpNoDelay(connection *conn);
|
||||
int connDisableTcpNoDelay(connection *conn);
|
||||
int connKeepAlive(connection *conn, int interval);
|
||||
int connSendTimeout(connection *conn, long long ms);
|
||||
int connRecvTimeout(connection *conn, long long ms);
|
||||
|
||||
/* The connection module does not deal with listening and accepting sockets,
|
||||
* so we assume we have a socket when an incoming connection is created.
|
||||
*
|
||||
@ -258,7 +268,16 @@ static inline int connSetWriteHandlerWithBarrier(connection *conn, ConnectionCal
|
||||
return conn->type->set_write_handler(conn, func, barrier);
|
||||
}
|
||||
|
||||
static inline void connShutdown(connection *conn) {
|
||||
static inline void connShutdown(connection *conn, int force) {
|
||||
if (force) {
|
||||
/*
|
||||
* When the 'force' flag is set, we perform a forceful shutdown of the
|
||||
* connection, regardless of whether it is currently blocked or not.
|
||||
* This is useful in situations where we need to terminate the connection
|
||||
* immediately, without waiting for any pending operations to complete.
|
||||
*/
|
||||
connNonBlock(conn);
|
||||
}
|
||||
conn->type->shutdown(conn);
|
||||
}
|
||||
|
||||
@ -374,15 +393,6 @@ static inline const char *connGetInfo(connection *conn, char *buf, size_t buf_le
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* anet-style wrappers to conns */
|
||||
int connBlock(connection *conn);
|
||||
int connNonBlock(connection *conn);
|
||||
int connEnableTcpNoDelay(connection *conn);
|
||||
int connDisableTcpNoDelay(connection *conn);
|
||||
int connKeepAlive(connection *conn, int interval);
|
||||
int connSendTimeout(connection *conn, long long ms);
|
||||
int connRecvTimeout(connection *conn, long long ms);
|
||||
|
||||
/* Get cert for the secure connection */
|
||||
static inline sds connGetPeerCert(connection *conn) {
|
||||
if (conn->type->get_peer_cert) {
|
||||
|
@ -1569,9 +1569,9 @@ void unlinkClient(client *c) {
|
||||
}
|
||||
/* Only use shutdown when the fork is active and we are the parent. */
|
||||
if (server.child_type && !c->flag.repl_rdb_channel) {
|
||||
connShutdown(c->conn);
|
||||
connShutdown(c->conn, 0);
|
||||
} else if (c->flag.repl_rdb_channel) {
|
||||
shutdown(c->conn->fd, SHUT_RDWR);
|
||||
connShutdown(c->conn, 1);
|
||||
}
|
||||
connClose(c->conn);
|
||||
c->conn = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user