Commit 27dadbd8 authored by Sergei Golubchik's avatar Sergei Golubchik

wt: don't support a key as a union { ulonglong, void* }. Although convenient,

it forces the user to bzero a key before setting it as a pointer, otherwise
it'll have random content on architectures where
sizeof(void*) < sizeof(ulonglong).

Declaring a key as ulonglong only (not a union) makes this user mistake
impossible.

include/waiting_threads.h:
  WT_RESOURCE_ID::value is an ulonglong, not a union
mysys/waiting_threads.c:
  WT_RESOURCE_ID::value is an ulonglong, not a union
storage/maria/ma_write.c:
  WT_RESOURCE_ID::value is an ulonglong, not a union
storage/maria/trnman.c:
  WT_RESOURCE_ID::value is an ulonglong, not a union
unittest/mysys/waiting_threads-t.c:
  WT_RESOURCE_ID::value is an ulonglong, not a union
parent 533deb0a
......@@ -32,10 +32,7 @@ typedef struct st_wt_resource_type {
struct st_wt_resource_id {
WT_RESOURCE_TYPE *type;
union {
void *ptr;
ulonglong num;
} value;
ulonglong value;
};
#define WT_WAIT_STATS 24
......
......@@ -30,8 +30,7 @@
A resource is represented by a WT_RESOURCE structure.
a resource identifier - a pair of {resource type, value}. A value is
either a ulonglong number or a pointer (it's a union).
WT_RESOURCE_ID structure.
an ulonglong number. Represented by a WT_RESOURCE_ID structure.
a resource type - a pointer to a statically defined instance of
WT_RESOURCE_TYPE structure. This structure contains a pointer to
......@@ -169,19 +168,19 @@ static my_atomic_rwlock_t cycle_stats_lock, wait_stats_lock, success_stats_lock;
#define rc_rdlock(X) \
do { \
WT_RESOURCE *R=(X); \
DBUG_PRINT("wt", ("LOCK resid=%lld for READ", R->id.value.num)); \
DBUG_PRINT("wt", ("LOCK resid=%lld for READ", R->id.value)); \
rw_rdlock(&R->lock); \
} while (0)
#define rc_wrlock(X) \
do { \
WT_RESOURCE *R=(X); \
DBUG_PRINT("wt", ("LOCK resid=%lld for WRITE", R->id.value.num)); \
DBUG_PRINT("wt", ("LOCK resid=%lld for WRITE", R->id.value)); \
rw_wrlock(&R->lock); \
} while (0)
#define rc_unlock(X) \
do { \
WT_RESOURCE *R=(X); \
DBUG_PRINT("wt", ("UNLOCK resid=%lld", R->id.value.num)); \
DBUG_PRINT("wt", ("UNLOCK resid=%lld", R->id.value)); \
rw_unlock(&R->lock); \
} while (0)
......@@ -688,7 +687,7 @@ int wt_thd_will_wait_for(WT_THD *thd, WT_THD *blocker, WT_RESOURCE_ID *resid)
LF_REQUIRE_PINS(3);
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, resid=%llu",
thd->name, blocker->name, resid->value.num));
thd->name, blocker->name, resid->value));
if (fix_thd_pins(thd))
DBUG_RETURN(WT_DEADLOCK);
......
......@@ -217,7 +217,7 @@ int maria_write(MARIA_HA *info, uchar *record)
int res;
rc.type= &ma_rc_dup_unique;
rc.value.ptr= blocker; /* TODO savepoint id when we'll have them */
rc.value= (intptr)blocker; /* TODO savepoint id when we'll have them */
res= wt_thd_will_wait_for(info->trn->wt, blocker->wt, & rc);
if (res != WT_OK)
{
......
......@@ -87,7 +87,7 @@ static void wt_thd_release_self(TRN *trn)
{
WT_RESOURCE_ID rc;
rc.type= &ma_rc_dup_unique;
rc.value.ptr= trn;
rc.value= (intptr)trn;
wt_thd_release(trn->wt, & rc);
trn->wt= 0;
}
......
......@@ -62,9 +62,8 @@ pthread_handler_t test_wt(void *arg)
{
WT_RESOURCE_ID resid;
int blockers[THREADS/10], j, k;
bzero(&resid, sizeof(resid));
resid.value.num= id;
resid.value= id;
resid.type= &restype;
res= 0;
......@@ -187,8 +186,7 @@ void do_tests()
WT_RESOURCE_ID resid[3];
for (i=0; i < 3; i++)
{
bzero(&resid[i], sizeof(resid[i]));
resid[i].value.num= i+1;
resid[i].value= i+1;
resid[i].type= &restype;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment