Reset client DCB pointer after closing it

The client DCB was not reset in one of the cases where it was closed.

Also fixed use of overlapping memory addresses in strcpy.
This commit is contained in:
Markus Mäkelä
2017-08-17 14:17:08 +03:00
parent 71ca174313
commit 6bdd959f6c
2 changed files with 4 additions and 1 deletions

View File

@ -555,7 +555,9 @@ blr_file_create(ROUTER_INSTANCE *router, char *orig_file)
{
close(router->binlog_fd);
spinlock_acquire(&router->binlog_lock);
strcpy(router->binlog_name, file);
int len = strlen(file);
memmove(router->binlog_name, file, len);
router->binlog_name[len] = '\0';
router->binlog_fd = fd;
/* Initial position after the magic number */
router->current_pos = BINLOG_MAGIC_SIZE;

View File

@ -340,6 +340,7 @@ static void
blr_restart_master(ROUTER_INSTANCE *router)
{
dcb_close(router->client);
router->client = NULL;
/* Now it is safe to unleash other threads on this router instance */
spinlock_acquire(&router->lock);