mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
Fix double-initalization of mutex in archive storage engine. (Bug #7762)
sql/examples/ha_archive.cc: Fix redundant initialization of share->mutex Fix error handling to always clean up correctly Fix a couple of warnings
This commit is contained in:
parent
c86ae20457
commit
4bb238a054
1 changed files with 17 additions and 14 deletions
|
@ -341,10 +341,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
|
||||||
if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL)
|
if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL)
|
||||||
goto error2;
|
goto error2;
|
||||||
if (my_hash_insert(&archive_open_tables, (byte*) share))
|
if (my_hash_insert(&archive_open_tables, (byte*) share))
|
||||||
goto error2;
|
|
||||||
thr_lock_init(&share->lock);
|
|
||||||
if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST))
|
|
||||||
goto error3;
|
goto error3;
|
||||||
|
thr_lock_init(&share->lock);
|
||||||
}
|
}
|
||||||
share->use_count++;
|
share->use_count++;
|
||||||
pthread_mutex_unlock(&archive_mutex);
|
pthread_mutex_unlock(&archive_mutex);
|
||||||
|
@ -352,14 +350,13 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table)
|
||||||
return share;
|
return share;
|
||||||
|
|
||||||
error3:
|
error3:
|
||||||
VOID(pthread_mutex_destroy(&share->mutex));
|
|
||||||
thr_lock_delete(&share->lock);
|
|
||||||
/* We close, but ignore errors since we already have errors */
|
/* We close, but ignore errors since we already have errors */
|
||||||
(void)gzclose(share->archive_write);
|
(void)gzclose(share->archive_write);
|
||||||
error2:
|
error2:
|
||||||
my_close(share->meta_file,MYF(0));
|
my_close(share->meta_file,MYF(0));
|
||||||
error:
|
error:
|
||||||
pthread_mutex_unlock(&archive_mutex);
|
pthread_mutex_unlock(&archive_mutex);
|
||||||
|
VOID(pthread_mutex_destroy(&share->mutex));
|
||||||
my_free((gptr) share, MYF(0));
|
my_free((gptr) share, MYF(0));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -493,22 +490,28 @@ int ha_archive::create(const char *name, TABLE *table_arg,
|
||||||
if ((archive= gzdopen(create_file, "ab")) == NULL)
|
if ((archive= gzdopen(create_file, "ab")) == NULL)
|
||||||
{
|
{
|
||||||
error= errno;
|
error= errno;
|
||||||
delete_table(name);
|
goto error2;
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
if (write_data_header(archive))
|
if (write_data_header(archive))
|
||||||
{
|
{
|
||||||
gzclose(archive);
|
error= errno;
|
||||||
|
goto error3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gzclose(archive)) {
|
||||||
|
error= errno;
|
||||||
goto error2;
|
goto error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gzclose(archive))
|
my_close(create_file, MYF(0));
|
||||||
goto error2;
|
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
|
error3:
|
||||||
|
/* We already have an error, so ignore results of gzclose. */
|
||||||
|
(void)gzclose(archive);
|
||||||
error2:
|
error2:
|
||||||
error= errno;
|
my_close(create_file, MYF(0));
|
||||||
delete_table(name);
|
delete_table(name);
|
||||||
error:
|
error:
|
||||||
/* Return error number, if we got one */
|
/* Return error number, if we got one */
|
||||||
|
@ -736,7 +739,7 @@ int ha_archive::rebuild_meta_file(char *table_name, File meta_file)
|
||||||
if ((rebuild_file= gzopen(data_file_name, "rb")) == NULL)
|
if ((rebuild_file= gzopen(data_file_name, "rb")) == NULL)
|
||||||
DBUG_RETURN(errno ? errno : -1);
|
DBUG_RETURN(errno ? errno : -1);
|
||||||
|
|
||||||
if (rc= read_data_header(rebuild_file))
|
if ((rc= read_data_header(rebuild_file)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -800,7 +803,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (read= gzread(reader, block, IO_SIZE))
|
while ((read= gzread(reader, block, IO_SIZE)))
|
||||||
gzwrite(writer, block, read);
|
gzwrite(writer, block, read);
|
||||||
|
|
||||||
gzclose(reader);
|
gzclose(reader);
|
||||||
|
|
Loading…
Add table
Reference in a new issue