Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
bcc0148b
Commit
bcc0148b
authored
Feb 29, 2020
by
Isaac Ackerman
Committed by
Sergei Petrunia
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved xpand_hosts back to heap, Fixed malformed data on out of memory
parent
8eeaebc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
storage/xpand/ha_xpand.cc
storage/xpand/ha_xpand.cc
+27
-14
storage/xpand/xpand_connection.cc
storage/xpand/xpand_connection.cc
+3
-3
No files found.
storage/xpand/ha_xpand.cc
View file @
bcc0148b
...
...
@@ -75,7 +75,7 @@ static MYSQL_SYSVAR_ENUM
//current list of clx hosts
static
PSI_rwlock_key
key_xpand_hosts
;
mysql_rwlock_t
xpand_hosts_lock
;
xpand_host_list
xpand_hosts
;
xpand_host_list
*
xpand_hosts
;
static
int
check_hosts
(
MYSQL_THD
thd
,
struct
st_mysql_sys_var
*
var
,
void
*
save
,
struct
st_mysql_value
*
value
)
...
...
@@ -86,35 +86,41 @@ static int check_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
if
(
!
val
)
return
HA_ERR_OUT_OF_MEM
;
xpand_host_list
*
list
=
static_cast
<
xpand_host_list
*>
(
thd_calloc
(
thd
,
sizeof
(
xpand_host_list
)));
if
(
!
list
)
return
HA_ERR_OUT_OF_MEM
;
xpand_host_list
list
;
memset
(
&
list
,
0
,
sizeof
(
list
));
int
error_code
=
0
;
if
((
error_code
=
list
->
fill
(
val
)))
if
((
error_code
=
list
.
fill
(
val
)))
return
error_code
;
list
->
empty
();
list
.
empty
();
*
static_cast
<
c
har
**>
(
save
)
=
thd_strdup
(
thd
,
val
)
;
*
static_cast
<
c
onst
char
**>
(
save
)
=
val
;
return
0
;
}
static
void
update_hosts
(
MYSQL_THD
thd
,
struct
st_mysql_sys_var
*
var
,
void
*
var_ptr
,
const
void
*
save
)
{
c
har
*
from_save
=
*
static_cast
<
char
*
const
*>
(
save
);
c
onst
char
*
from_save
=
*
static_cast
<
const
char
*
const
*>
(
save
);
mysql_rwlock_wrlock
(
&
xpand_hosts_lock
);
xpand_hosts
.
empty
();
int
error_code
=
xpand_hosts
.
fill
(
from_save
);
xpand_host_list
*
list
=
static_cast
<
xpand_host_list
*>
(
my_malloc
(
sizeof
(
xpand_host_list
),
MYF
(
MY_WME
|
MY_ZEROFILL
)));
int
error_code
=
list
->
fill
(
from_save
);
if
(
error_code
)
{
my_free
(
list
);
my_printf_error
(
error_code
,
"Unhandled error setting xpand hostlist"
,
MYF
(
0
));
return
;
}
*
static_cast
<
char
**>
(
var_ptr
)
=
my_strdup
(
from_save
,
MYF
(
MY_WME
));
xpand_hosts
->
empty
();
my_free
(
xpand_hosts
);
xpand_hosts
=
list
;
char
**
display_var
=
static_cast
<
char
**>
(
var_ptr
);
my_free
(
*
display_var
);
*
display_var
=
my_strdup
(
from_save
,
MYF
(
MY_WME
));
mysql_rwlock_unlock
(
&
xpand_hosts_lock
);
}
...
...
@@ -1474,7 +1480,13 @@ static int xpand_init(void *p)
mysql_rwlock_init
(
key_xpand_hosts
,
&
xpand_hosts_lock
);
mysql_rwlock_wrlock
(
&
xpand_hosts_lock
);
int
error_code
=
xpand_hosts
.
fill
(
xpand_hosts_str
);
xpand_hosts
=
static_cast
<
xpand_host_list
*>
(
my_malloc
(
sizeof
(
xpand_host_list
),
MYF
(
MY_WME
|
MY_ZEROFILL
)));
int
error_code
=
xpand_hosts
->
fill
(
xpand_hosts_str
);
if
(
error_code
)
{
my_free
(
xpand_hosts
);
xpand_hosts
=
NULL
;
}
mysql_rwlock_unlock
(
&
xpand_hosts_lock
);
DBUG_RETURN
(
error_code
);
}
...
...
@@ -1483,7 +1495,8 @@ static int xpand_deinit(void *p)
{
DBUG_ENTER
(
"xpand_deinit"
);
mysql_rwlock_wrlock
(
&
xpand_hosts_lock
);
xpand_hosts
.
empty
();
xpand_hosts
->
empty
();
xpand_hosts
=
NULL
;
mysql_rwlock_destroy
(
&
xpand_hosts_lock
);
DBUG_RETURN
(
0
);
}
...
...
storage/xpand/xpand_connection.cc
View file @
bcc0148b
...
...
@@ -129,7 +129,7 @@ extern int xpand_hosts_cur;
extern
ulong
xpand_balance_algorithm
;
extern
mysql_rwlock_t
xpand_hosts_lock
;
extern
xpand_host_list
xpand_hosts
;
extern
xpand_host_list
*
xpand_hosts
;
int
xpand_connection
::
connect
()
{
...
...
@@ -142,8 +142,8 @@ int xpand_connection::connect()
//search for available host
int
error_code
=
ER_BAD_HOST_ERROR
;
for
(
int
i
=
0
;
i
<
xpand_hosts
.
hosts_len
;
i
++
)
{
char
*
host
=
xpand_hosts
.
hosts
[(
start
+
i
)
%
xpand_hosts
.
hosts_len
];
for
(
int
i
=
0
;
i
<
xpand_hosts
->
hosts_len
;
i
++
)
{
char
*
host
=
xpand_hosts
->
hosts
[(
start
+
i
)
%
xpand_hosts
->
hosts_len
];
error_code
=
connect_direct
(
host
);
if
(
!
error_code
)
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment