mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-12-02 03:47:41 +08:00
Optimize salt seed supply
This commit is contained in:
parent
1070d4a08c
commit
35da263e43
@ -17,7 +17,11 @@
|
||||
02110-1301 USA
|
||||
|
||||
$%ENDLICENSE%$ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -18,7 +18,10 @@
|
||||
|
||||
$%ENDLICENSE%$ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
@ -502,6 +502,7 @@ init_parameters(struct chassis_frontend_t *frontend, chassis *srv)
|
||||
srv->cache_index = g_queue_new();
|
||||
}
|
||||
srv->is_tcp_stream_enabled = frontend->is_tcp_stream_enabled;
|
||||
srv->is_tcp_stream_enabled = 1;
|
||||
if (srv->is_tcp_stream_enabled) {
|
||||
g_message("%s:tcp stream enabled", G_STRLOC);
|
||||
}
|
||||
|
@ -124,18 +124,22 @@ network_backend_conns_count(network_backend_t *b)
|
||||
void
|
||||
network_backend_save_challenge(network_backend_t *b, const network_mysqld_auth_challenge *chal)
|
||||
{
|
||||
if (b->challenges->len < 256) {
|
||||
static const guint32 not_supported = CLIENT_SSL | CLIENT_LOCAL_FILES | CLIENT_DEPRECATE_EOF;
|
||||
|
||||
network_mysqld_auth_challenge *challenge = network_mysqld_auth_challenge_copy(chal);
|
||||
|
||||
challenge->capabilities &= ~not_supported;
|
||||
char *old_str = challenge->server_version_str;
|
||||
challenge->server_version_str = g_strdup_printf("%s (%s)", old_str, PACKAGE_STRING);
|
||||
g_free(old_str);
|
||||
|
||||
g_ptr_array_add(b->challenges, challenge);
|
||||
if (b->challenges->len >= 1024) {
|
||||
network_mysqld_auth_challenge *challenge;
|
||||
challenge = g_ptr_array_remove_index(b->challenges, 0);
|
||||
network_mysqld_auth_challenge_free(challenge);
|
||||
}
|
||||
|
||||
static const guint32 not_supported = CLIENT_SSL | CLIENT_LOCAL_FILES | CLIENT_DEPRECATE_EOF;
|
||||
|
||||
network_mysqld_auth_challenge *challenge = network_mysqld_auth_challenge_copy(chal);
|
||||
|
||||
challenge->capabilities &= ~not_supported;
|
||||
char *old_str = challenge->server_version_str;
|
||||
challenge->server_version_str = g_strdup_printf("%s (%s)", old_str, PACKAGE_STRING);
|
||||
g_free(old_str);
|
||||
|
||||
g_ptr_array_add(b->challenges, challenge);
|
||||
}
|
||||
|
||||
struct network_mysqld_auth_challenge *
|
||||
@ -145,8 +149,10 @@ network_backend_get_challenge(network_backend_t *b)
|
||||
g_message("challenges len 0 for backend:%s", b->addr->name->str);
|
||||
return NULL;
|
||||
}
|
||||
int ndx = b->chal_ndx % b->challenges->len;
|
||||
b->chal_ndx++;
|
||||
|
||||
int ndx = g_random_int_range(0, 1024);
|
||||
ndx = ndx % b->challenges->len;
|
||||
|
||||
network_mysqld_auth_challenge *challenge = g_ptr_array_index(b->challenges, ndx);
|
||||
return challenge;
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ typedef struct {
|
||||
|
||||
backend_config *config;
|
||||
GPtrArray *challenges;
|
||||
int chal_ndx;
|
||||
time_t last_check_time;
|
||||
int slave_delay_msec; /* valid if this is a ReadOnly slave */
|
||||
} network_backend_t;
|
||||
|
@ -22,7 +22,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <sys/uio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -18,7 +18,10 @@
|
||||
|
||||
$%ENDLICENSE%$ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
Loading…
Reference in New Issue
Block a user