mirror of
http://github.com/valkey-io/valkey
synced 2024-11-23 03:33:28 +00:00
parent
62fc7f4f24
commit
4b8d8826af
@ -691,6 +691,13 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the approximated number of sockets we are using in order to
|
||||||
|
* take the cluster bus connections. */
|
||||||
|
unsigned long getClusterConnectionsCount(void) {
|
||||||
|
return server.cluster_enabled ?
|
||||||
|
(dictSize(server.cluster->nodes)*2) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Key space handling
|
* Key space handling
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
@ -283,5 +283,6 @@ typedef struct {
|
|||||||
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
|
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
|
||||||
int clusterRedirectBlockedClientIfNeeded(client *c);
|
int clusterRedirectBlockedClientIfNeeded(client *c);
|
||||||
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
||||||
|
unsigned long getClusterConnectionsCount(void);
|
||||||
|
|
||||||
#endif /* __CLUSTER_H */
|
#endif /* __CLUSTER_H */
|
||||||
|
@ -892,17 +892,24 @@ static void acceptCommonHandler(connection *conn, int flags, char *ip) {
|
|||||||
client *c;
|
client *c;
|
||||||
UNUSED(ip);
|
UNUSED(ip);
|
||||||
|
|
||||||
/* Admission control will happen before a client is created and connAccept()
|
/* Limit the number of connections we take at the same time.
|
||||||
|
*
|
||||||
|
* Admission control will happen before a client is created and connAccept()
|
||||||
* called, because we don't want to even start transport-level negotiation
|
* called, because we don't want to even start transport-level negotiation
|
||||||
* if rejected.
|
* if rejected. */
|
||||||
*/
|
if (listLength(server.clients) + getClusterConnectionsCount()
|
||||||
if (listLength(server.clients) >= server.maxclients) {
|
>= server.maxclients)
|
||||||
char *err = "-ERR max number of clients reached\r\n";
|
{
|
||||||
|
char *err;
|
||||||
|
if (server.cluster_enabled)
|
||||||
|
err = "-ERR max number of clients reached\r\n";
|
||||||
|
else
|
||||||
|
err = "-ERR max number of clients + cluster "
|
||||||
|
"connections reached\r\n";
|
||||||
|
|
||||||
/* That's a best effort error message, don't check write errors.
|
/* That's a best effort error message, don't check write errors.
|
||||||
* Note that for TLS connections, no handshake was done yet so nothing is written
|
* Note that for TLS connections, no handshake was done yet so nothing
|
||||||
* and the connection will just drop.
|
* is written and the connection will just drop. */
|
||||||
*/
|
|
||||||
if (connWrite(conn,err,strlen(err)) == -1) {
|
if (connWrite(conn,err,strlen(err)) == -1) {
|
||||||
/* Nothing to do, Just to avoid the warning... */
|
/* Nothing to do, Just to avoid the warning... */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user