Getting optional LMDB support into Cytoplasm #43
1 changed files with 13 additions and 10 deletions
|
@ -159,7 +159,6 @@ LMDBLock(Db *d, Array *k)
|
||||||
"%s: could not begin transaction: %s",
|
"%s: could not begin transaction: %s",
|
||||||
__func__, mdb_strerror(code)
|
__func__, mdb_strerror(code)
|
||||||
);
|
);
|
||||||
pthread_mutex_unlock(&d->lock);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
/* apparently you need to give it a dbi */
|
/* apparently you need to give it a dbi */
|
||||||
|
@ -169,9 +168,7 @@ LMDBLock(Db *d, Array *k)
|
||||||
"%s: could not get transaction dbi: %s",
|
"%s: could not get transaction dbi: %s",
|
||||||
__func__, mdb_strerror(code)
|
__func__, mdb_strerror(code)
|
||||||
);
|
);
|
||||||
pthread_mutex_unlock(&d->lock);
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
empty_json.mv_size = 0;
|
empty_json.mv_size = 0;
|
||||||
|
@ -180,10 +177,7 @@ LMDBLock(Db *d, Array *k)
|
||||||
code = mdb_get(transaction, dbi, &key, &empty_json);
|
code = mdb_get(transaction, dbi, &key, &empty_json);
|
||||||
if (code == MDB_NOTFOUND)
|
if (code == MDB_NOTFOUND)
|
||||||
{
|
{
|
||||||
Log(LOG_ERR,
|
/* No use logging it, as that is just locking behaviour */
|
||||||
"%s: mdb_get failure: %s",
|
|
||||||
__func__, mdb_strerror(code)
|
|
||||||
);
|
|
||||||
mdb_txn_abort(transaction);
|
mdb_txn_abort(transaction);
|
||||||
mdb_dbi_close(db->environ, dbi);
|
mdb_dbi_close(db->environ, dbi);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -215,6 +209,10 @@ LMDBLock(Db *d, Array *k)
|
||||||
ret->transaction = transaction;
|
ret->transaction = transaction;
|
||||||
ret->dbi = dbi;
|
ret->dbi = dbi;
|
||||||
end:
|
end:
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&d->lock);
|
||||||
|
}
|
||||||
LMDBKillKey(key);
|
LMDBKillKey(key);
|
||||||
return (DbRef *) ret;
|
return (DbRef *) ret;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +349,10 @@ LMDBUnlock(Db *d, DbRef *r)
|
||||||
{
|
{
|
||||||
free(val.mv_data);
|
free(val.mv_data);
|
||||||
}
|
}
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
pthread_mutex_unlock(&d->lock);
|
pthread_mutex_unlock(&d->lock);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
static DbRef *
|
static DbRef *
|
||||||
|
@ -379,7 +380,6 @@ LMDBCreate(Db *d, Array *k)
|
||||||
"%s: could not begin transaction: %s",
|
"%s: could not begin transaction: %s",
|
||||||
__func__, mdb_strerror(code)
|
__func__, mdb_strerror(code)
|
||||||
);
|
);
|
||||||
pthread_mutex_unlock(&d->lock);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
/* apparently you need to give it a dbi */
|
/* apparently you need to give it a dbi */
|
||||||
|
@ -389,7 +389,6 @@ LMDBCreate(Db *d, Array *k)
|
||||||
"%s: could not get transaction dbi: %s",
|
"%s: could not get transaction dbi: %s",
|
||||||
__func__, mdb_strerror(code)
|
__func__, mdb_strerror(code)
|
||||||
);
|
);
|
||||||
pthread_mutex_unlock(&d->lock);
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -435,6 +434,10 @@ LMDBCreate(Db *d, Array *k)
|
||||||
ret->transaction = transaction;
|
ret->transaction = transaction;
|
||||||
ret->dbi = dbi;
|
ret->dbi = dbi;
|
||||||
end:
|
end:
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&d->lock);
|
||||||
|
}
|
||||||
LMDBKillKey(key);
|
LMDBKillKey(key);
|
||||||
return (DbRef *) ret;
|
return (DbRef *) ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue