Browse Source

ckdb - fix some more locking anomalies

master
kanoi 9 years ago
parent
commit
c7ae476538
  1. 11
      src/ckdb.c
  2. 2
      src/ckdb.h
  3. 4
      src/ckdb_cmd.c
  4. 2
      src/klist.h

11
src/ckdb.c

@ -1746,7 +1746,7 @@ static void trans_process(SEQSET *seqset, tv_t *now, K_STORE *store)
seqtrans->seq = seq;
seqtrans->seqnum = u;
memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY));
k_add_head(store, st_item);
k_add_head_nolock(store, st_item);
}
u++;
seqentry++;
@ -1772,7 +1772,7 @@ static void trans_process(SEQSET *seqset, tv_t *now, K_STORE *store)
seqtrans->seq = seq;
seqtrans->seqnum = u;
memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY));
k_add_head(store, st_item);
k_add_head_nolock(store, st_item);
}
u++;
seqentry++;
@ -2143,7 +2143,7 @@ gotseqset:
sizeof(SEQENTRY));
if (!lost)
lost = k_new_store(seqtrans_free);
k_add_tail(lost, st_item);
k_add_tail_nolock(lost, st_item);
seqdata->lost++;
seqset->lost++;
if (ENTRYISTRANS(u_entry)) {
@ -2173,7 +2173,7 @@ gotseqset:
seqdata->reload_lost = k_new_store(seqtrans_free);
seqdata_reload_lost = true;
}
k_add_tail(seqdata->reload_lost, stl_item);
k_add_tail_nolock(seqdata->reload_lost, stl_item);
}
} else {
// (u-size) wasn't missing
@ -2254,8 +2254,7 @@ gotseqset:
}
if (st_item) {
// recovered a lost entry
k_unlink_item(seqtrans_free, st_item);
// N.B. lock inside lock
k_unlink_item_nolock(seqdata->reload_lost, st_item);
K_WLOCK(seqtrans_free);
k_add_head(seqtrans_free, st_item);
K_WUNLOCK(seqtrans_free);

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.611"
#define CKDB_VERSION DB_VERSION"-1.612"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__

4
src/ckdb_cmd.c

@ -3636,9 +3636,9 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id,
}
}
if (!ua_item) {
K_RLOCK(useratts_free);
K_WLOCK(useratts_free);
ua_item = k_unlink_head(useratts_free);
K_RUNLOCK(useratts_free);
K_WUNLOCK(useratts_free);
DATA_USERATTS(useratts, ua_item);
bzero(useratts, sizeof(*useratts));
useratts->userid = users->userid;

2
src/klist.h

@ -586,7 +586,7 @@ extern void _k_insert_after(K_LIST *list, K_ITEM *item, K_ITEM *after, LOCK_MAYB
//#define k_insert_after_nolock(_list, _item, _after) _k_insert_after(_list, _item, _after, false, KLIST_FFL_HERE)
extern void _k_unlink_item(K_LIST *list, K_ITEM *item, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS);
#define k_unlink_item(_list, _item) _k_unlink_item(_list, _item, true, KLIST_FFL_HERE)
//#define k_unlink_item_nolock(_list, _item) _k_unlink_item(_list, _item, false, KLIST_FFL_HERE)
#define k_unlink_item_nolock(_list, _item) _k_unlink_item(_list, _item, false, KLIST_FFL_HERE)
extern void _k_list_transfer_to_head(K_LIST *from, K_LIST *to, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS);
#define k_list_transfer_to_head(_from, _to) _k_list_transfer_to_head(_from, _to, true, KLIST_FFL_HERE)
//#define k_list_transfer_to_head_nolock(_from, _to) _k_list_transfer_to_head(_from, _to, false, KLIST_FFL_HERE)

Loading…
Cancel
Save