1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
1. factored XID-related functions to a separate wsrep_xid.cc unit.
  2. refactored them to take refrences instead of pointers where appropriate
  3. implemented wsrep_get/set_SE_position to take wsrep_uuid_t and wsrep_seqno_t instead of XID
  4. call wsrep_set_SE_position() in wsrep_sst_received() to reinitialize SE checkpoint after SST was received, avoid assert() in setting code by first checking current position.
This commit is contained in:
Alexey Yurchenko
2015-03-23 23:27:28 +02:00
committed by Nirbhay Choubey
parent f5bce5a600
commit 4ed9ddd30e
16 changed files with 292 additions and 199 deletions

View File

@ -1,4 +1,4 @@
/* Copyright 2010 Codership Oy <http://www.codership.com>
/* Copyright 2010-2015 Codership Oy <http://www.codership.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -467,58 +467,3 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
return 0;
}
/*
* WSREPXid
*/
#define WSREP_XID_PREFIX "WSREPXid"
#define WSREP_XID_PREFIX_LEN MYSQL_XID_PREFIX_LEN
#define WSREP_XID_UUID_OFFSET 8
#define WSREP_XID_SEQNO_OFFSET (WSREP_XID_UUID_OFFSET + sizeof(wsrep_uuid_t))
#define WSREP_XID_GTRID_LEN (WSREP_XID_SEQNO_OFFSET + sizeof(wsrep_seqno_t))
void wsrep_xid_init(XID* xid, const wsrep_uuid_t* uuid, wsrep_seqno_t seqno)
{
xid->formatID= 1;
xid->gtrid_length= WSREP_XID_GTRID_LEN;
xid->bqual_length= 0;
memset(xid->data, 0, sizeof(xid->data));
memcpy(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN);
memcpy(xid->data + WSREP_XID_UUID_OFFSET, uuid, sizeof(wsrep_uuid_t));
memcpy(xid->data + WSREP_XID_SEQNO_OFFSET, &seqno, sizeof(wsrep_seqno_t));
}
const wsrep_uuid_t* wsrep_xid_uuid(const XID* xid)
{
if (wsrep_is_wsrep_xid(xid))
return reinterpret_cast<const wsrep_uuid_t*>(xid->data
+ WSREP_XID_UUID_OFFSET);
else
return &WSREP_UUID_UNDEFINED;
}
wsrep_seqno_t wsrep_xid_seqno(const XID* xid)
{
if (wsrep_is_wsrep_xid(xid))
{
wsrep_seqno_t seqno;
memcpy(&seqno, xid->data + WSREP_XID_SEQNO_OFFSET, sizeof(wsrep_seqno_t));
return seqno;
}
else
{
return WSREP_SEQNO_UNDEFINED;
}
}
extern
int wsrep_is_wsrep_xid(const void* xid_ptr)
{
const XID* xid= reinterpret_cast<const XID*>(xid_ptr);
return (xid->formatID == 1 &&
xid->gtrid_length == WSREP_XID_GTRID_LEN &&
xid->bqual_length == 0 &&
!memcmp(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN));
}