Skip to content

Commit

Permalink
Merge branch 'master' into unstable
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/db_impl.cpp
  • Loading branch information
huangjiahua committed Jul 3, 2019
2 parents eb39ea1 + 8ab913e commit a88537b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/rsdb/rsdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DB {

bool Get(const std::string &key, std::string *data);

int Delete(const std::string &key);
bool Delete(const std::string &key);

bool Valid() const;

Expand Down
2 changes: 1 addition & 1 deletion src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool rsdb::DB::Get(const std::string &key, std::string *data) {
return ret;
}

int rsdb::DB::Delete(const std::string &key) {
bool rsdb::DB::Delete(const std::string &key) {
Slice key_slice(key);
return impl_->Delete(key_slice);
}
Expand Down
9 changes: 4 additions & 5 deletions src/db_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,20 @@ char *rsdb::DB::DBImpl::DBReadDat(DBContext *ct) {
return (ct->datbuf);
}

int rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) {
int rc = 0;
DBContext ct;
bool rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) {
bool ret = true;

lock_guard lk(idx_muts[DBHash(key) + 1]);
if (DBFindAndLock(&ct, key, true) == 0) {
DBDoDelete(&ct);
this->cnt_delok++;
} else {
rc = -1;
ret = false;
this->cnt_delerr++;
}
if (un_lock(this->idxfd, ct.chainoff, SEEK_SET, 1) < 0)
err_dump("DBImpl::Delete: un_lock error");
return (rc);
return ret;
}

void rsdb::DB::DBImpl::DBDoDelete(DBContext *ct) {
Expand Down
2 changes: 1 addition & 1 deletion src/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct rsdb::DB::DBImpl {

bool Get(const Slice &key, Slice *data);

int Delete(const Slice &key);
bool Delete(const Slice &key);

bool Valid() const;

Expand Down

0 comments on commit a88537b

Please sign in to comment.