Skip to content

Commit

Permalink
* IW_ERROR_INVALID_STATE errors wraped by verbose log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
adamansky committed Feb 17, 2020
1 parent b2f7b00 commit e19a9f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ejdb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static iwrc _jb_coll_init(JBCOLL jbc, IWKV_val *meta) {
RCRET(rc);
}
if (!jbc->meta) {
iwlog_error("Collection %s seems to be initialized", jbc->name);
return IW_ERROR_INVALID_STATE;
}
rc = _jb_coll_load_meta_lr(jbc);
Expand Down Expand Up @@ -1694,6 +1695,7 @@ iwrc ejdb_close(EJDB *ejdbp) {
}
EJDB db = *ejdbp;
if (!__sync_bool_compare_and_swap(&db->open, 1, 0)) {
iwlog_error2("Database is closed already");
return IW_ERROR_INVALID_STATE;
}
iwrc rc = _jb_db_release(ejdbp);
Expand Down
7 changes: 5 additions & 2 deletions src/ejdb2_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ static_assert(JBNUMBUF_SIZE >= IWFTOA_BUFSIZE, "JBNUMBUF_SIZE >= IWFTOA_BUFSIZE"
#define KEY_PREFIX_COLLMETA "c." // Full key format: c.<coldbid>
#define KEY_PREFIX_IDXMETA "i." // Full key format: i.<coldbid>.<idxdbid>

#define ENSURE_OPEN(db_) \
if (!(db_) || !((db_)->open)) return IW_ERROR_INVALID_STATE;
#define ENSURE_OPEN(db_) \
if (!(db_) || !((db_)->open)) { \
iwlog_error("Database is not open"); \
return IW_ERROR_INVALID_STATE; \
}

#define API_RLOCK(db_, rci_) \
ENSURE_OPEN(db_); \
Expand Down

0 comments on commit e19a9f6

Please sign in to comment.