mirror of https://gitee.com/bigwinds/arangodb
fixed segfault
This commit is contained in:
parent
66d790728a
commit
a241c6959e
|
@ -423,7 +423,6 @@ namespace triagens {
|
|||
int res = this->lock(trxCollection, TRI_TRANSACTION_READ);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||
TRI_FreeBarrier(*barrier);
|
||||
*barrier = 0;
|
||||
return res;
|
||||
|
@ -486,7 +485,6 @@ namespace triagens {
|
|||
int res = this->lock(trxCollection, TRI_TRANSACTION_READ);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -533,7 +531,6 @@ namespace triagens {
|
|||
int res = this->lock(trxCollection, TRI_TRANSACTION_READ);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
this->unlock(trxCollection, TRI_TRANSACTION_READ);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -770,6 +767,7 @@ namespace triagens {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief truncate a collection
|
||||
/// the caller must make sure a barrier is held
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int removeAll (TRI_transaction_collection_t* const trxCollection,
|
||||
|
@ -777,25 +775,25 @@ namespace triagens {
|
|||
|
||||
vector<string> ids;
|
||||
|
||||
int res = readAll(trxCollection, ids);
|
||||
TRI_primary_collection_t* primary = primaryCollection(trxCollection);
|
||||
|
||||
// WRITE-LOCK START
|
||||
int res = this->lock(trxCollection, TRI_TRANSACTION_WRITE);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = readAll(trxCollection, ids);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
this->unlock(trxCollection, TRI_TRANSACTION_WRITE);
|
||||
return res;
|
||||
}
|
||||
|
||||
TRI_doc_update_policy_t updatePolicy;
|
||||
TRI_InitUpdatePolicy(&updatePolicy, TRI_DOC_UPDATE_LAST_WRITE, 0, NULL);
|
||||
|
||||
size_t n = ids.size();
|
||||
|
||||
TRI_primary_collection_t* primary = primaryCollection(trxCollection);
|
||||
|
||||
// WRITE-LOCK START
|
||||
res = this->lock(trxCollection, TRI_TRANSACTION_WRITE);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
const size_t n = ids.size();
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
const string& id = ids[i];
|
||||
|
|
|
@ -5455,18 +5455,26 @@ static v8::Handle<v8::Value> JS_TruncateVocbaseCol (v8::Arguments const& argv) {
|
|||
if (col == 0) {
|
||||
TRI_V8_EXCEPTION_INTERNAL(scope, "cannot extract collection");
|
||||
}
|
||||
|
||||
|
||||
CollectionNameResolver resolver(col->_vocbase);
|
||||
SingleCollectionWriteTransaction<EmbeddableTransaction<V8TransactionContext>, UINT64_MAX> trx(col->_vocbase, resolver, col->_cid);
|
||||
int res = trx.begin();
|
||||
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_V8_EXCEPTION_MESSAGE(scope, res, "cannot truncate collection");
|
||||
}
|
||||
|
||||
TRI_barrier_t* barrier = TRI_CreateBarrierElement(&(trx.primaryCollection()->_barrierList));
|
||||
|
||||
if (barrier == 0) {
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
}
|
||||
|
||||
res = trx.truncate(forceSync);
|
||||
res = trx.finish(res);
|
||||
|
||||
TRI_FreeBarrier(barrier);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_V8_EXCEPTION_MESSAGE(scope, res, "cannot truncate collection");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue