mirror of https://gitee.com/bigwinds/arangodb
fixed wrong return value
This commit is contained in:
parent
fbad5735b1
commit
25d779dcad
|
@ -149,6 +149,7 @@ static bool CloseJournal (TRI_blob_collection_t* collection, TRI_datafile_t* jou
|
|||
char* dname;
|
||||
char* filename;
|
||||
char* number;
|
||||
int res;
|
||||
size_t i;
|
||||
size_t n;
|
||||
|
||||
|
@ -171,9 +172,9 @@ static bool CloseJournal (TRI_blob_collection_t* collection, TRI_datafile_t* jou
|
|||
}
|
||||
|
||||
// seal and rename datafile
|
||||
ok = TRI_SealDatafile(journal);
|
||||
res = TRI_SealDatafile(journal);
|
||||
|
||||
if (! ok) {
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
collection->base._state = TRI_COL_STATE_WRITE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -839,25 +839,22 @@ bool TRI_RenameDatafile (TRI_datafile_t* datafile, char const* filename) {
|
|||
/// @brief seals a database, writes a footer, sets it to read-only
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_SealDatafile (TRI_datafile_t* datafile) {
|
||||
int TRI_SealDatafile (TRI_datafile_t* datafile) {
|
||||
TRI_df_footer_marker_t footer;
|
||||
TRI_df_marker_t* position;
|
||||
bool ok;
|
||||
int res;
|
||||
|
||||
if (datafile->_state == TRI_DF_STATE_READ) {
|
||||
TRI_set_errno(TRI_ERROR_AVOCADO_READ_ONLY);
|
||||
return false;
|
||||
return TRI_set_errno(TRI_ERROR_AVOCADO_READ_ONLY);
|
||||
}
|
||||
|
||||
if (datafile->_state != TRI_DF_STATE_WRITE) {
|
||||
TRI_set_errno(TRI_ERROR_AVOCADO_ILLEGAL_STATE);
|
||||
return false;
|
||||
return TRI_set_errno(TRI_ERROR_AVOCADO_ILLEGAL_STATE);
|
||||
}
|
||||
|
||||
if (datafile->_isSealed) {
|
||||
TRI_set_errno(TRI_ERROR_AVOCADO_DATAFILE_SEALED);
|
||||
return false;
|
||||
return TRI_set_errno(TRI_ERROR_AVOCADO_DATAFILE_SEALED);
|
||||
}
|
||||
|
||||
// create the footer
|
||||
|
@ -880,7 +877,7 @@ bool TRI_SealDatafile (TRI_datafile_t* datafile) {
|
|||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return false;
|
||||
return res;
|
||||
}
|
||||
|
||||
// sync file
|
||||
|
@ -911,8 +908,9 @@ bool TRI_SealDatafile (TRI_datafile_t* datafile) {
|
|||
res = ftruncate(datafile->_fd, datafile->_currentSize);
|
||||
|
||||
if (res < 0) {
|
||||
TRI_set_errno(TRI_ERROR_SYS_ERROR);
|
||||
LOG_ERROR("cannot truncate datafile '%s': %s", datafile->_filename, TRI_last_error());
|
||||
datafile->_lastError = TRI_set_errno(TRI_ERROR_SYS_ERROR);
|
||||
ok = false;
|
||||
}
|
||||
|
||||
datafile->_isSealed = true;
|
||||
|
|
|
@ -478,7 +478,7 @@ bool TRI_CloseDatafile (TRI_datafile_t* datafile);
|
|||
/// @brief seals a database, writes a footer, sets it to read-only
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_SealDatafile (TRI_datafile_t* datafile);
|
||||
int TRI_SealDatafile (TRI_datafile_t* datafile);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief renames a datafile
|
||||
|
|
|
@ -353,12 +353,14 @@ static bool CloseJournalDocCollection (TRI_doc_collection_t* collection,
|
|||
TRI_datafile_t* journal;
|
||||
TRI_vector_pointer_t* vector;
|
||||
bool ok;
|
||||
int res;
|
||||
char* dname;
|
||||
char* filename;
|
||||
char* number;
|
||||
|
||||
// either use a journal or a compactor
|
||||
if (compactor) {
|
||||
vector = &collection->base._journals;
|
||||
vector = &collection->base._compactors;
|
||||
}
|
||||
else {
|
||||
vector = &collection->base._journals;
|
||||
|
@ -372,9 +374,11 @@ static bool CloseJournalDocCollection (TRI_doc_collection_t* collection,
|
|||
|
||||
// seal and rename datafile
|
||||
journal = vector->_buffer[position];
|
||||
ok = TRI_SealDatafile(journal);
|
||||
res = TRI_SealDatafile(journal);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("failed to seal datafile '%s': %s", journal->_filename, TRI_last_error());
|
||||
|
||||
if (! ok) {
|
||||
TRI_RemoveVectorPointer(vector, position);
|
||||
TRI_PushBackVectorPointer(&collection->base._datafiles, journal);
|
||||
|
||||
|
@ -382,24 +386,8 @@ static bool CloseJournalDocCollection (TRI_doc_collection_t* collection,
|
|||
}
|
||||
|
||||
number = TRI_StringUInt32(journal->_fid);
|
||||
if (!number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dname = TRI_Concatenate3String("datafile-", number, ".db");
|
||||
/* TODO FIXME: memory allocation might fail */
|
||||
if (!dname) {
|
||||
TRI_FreeString(number);
|
||||
return false;
|
||||
}
|
||||
|
||||
filename = TRI_Concatenate2File(collection->base._directory, dname);
|
||||
/* TODO FIXME: memory allocation might fail */
|
||||
if (!filename) {
|
||||
TRI_FreeString(number);
|
||||
TRI_FreeString(dname);
|
||||
return false;
|
||||
}
|
||||
|
||||
TRI_FreeString(dname);
|
||||
TRI_FreeString(number);
|
||||
|
@ -407,6 +395,8 @@ static bool CloseJournalDocCollection (TRI_doc_collection_t* collection,
|
|||
ok = TRI_RenameDatafile(journal, filename);
|
||||
|
||||
if (! ok) {
|
||||
LOG_ERROR("failed to rename datafile '%s' to '%s': %s", journal->_filename, filename, TRI_last_error());
|
||||
|
||||
TRI_RemoveVectorPointer(vector, position);
|
||||
TRI_PushBackVectorPointer(&collection->base._datafiles, journal);
|
||||
TRI_FreeString(filename);
|
||||
|
|
|
@ -148,7 +148,7 @@ extern size_t PageSize;
|
|||
/// @brief minimal collection journal size
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_JOURNAL_MINIMAL_SIZE (1024 * 1024 * 128)
|
||||
#define TRI_JOURNAL_MINIMAL_SIZE (1024 * 1024)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document handle separator as character
|
||||
|
|
Loading…
Reference in New Issue