mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-14 04:20:02 +00:00
Fix version handling code to be B spec compliant.
BUG 623. (Logical change 1.206) git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@665 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
221aa61328
commit
1f1f048efc
54
lib/util.c
54
lib/util.c
@ -566,23 +566,63 @@ saHandleInstancePut (
|
||||
|
||||
SaErrorT
|
||||
saVersionVerify (
|
||||
struct saVersionDatabase *versionDatabase,
|
||||
const SaVersionT *version)
|
||||
struct saVersionDatabase *versionDatabase,
|
||||
SaVersionT *version)
|
||||
{
|
||||
int found = 0;
|
||||
int i;
|
||||
SaErrorT error = SA_AIS_ERR_VERSION;
|
||||
|
||||
if (version == 0) {
|
||||
return (SA_AIS_ERR_VERSION);
|
||||
return (SA_AIS_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for a release code that we support. If we find it then
|
||||
* make sure that the supported major version is >= to the required one.
|
||||
* In any case we return what we support in the version structure.
|
||||
*/
|
||||
for (i = 0; i < versionDatabase->versionCount; i++) {
|
||||
if (memcmp (&versionDatabase->versionsSupported[i], version, sizeof (SaVersionT)) == 0) {
|
||||
found = 1;
|
||||
|
||||
/*
|
||||
* Check if the caller requires and old release code that we don't support.
|
||||
*/
|
||||
if (version->releaseCode < versionDatabase->versionsSupported[i].releaseCode) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we can support this release code.
|
||||
*/
|
||||
if (version->releaseCode == versionDatabase->versionsSupported[i].releaseCode) {
|
||||
|
||||
/*
|
||||
* Check if we can support the major version requested.
|
||||
*/
|
||||
if (versionDatabase->versionsSupported[i].major >= version->major) {
|
||||
error = SA_AIS_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* We support the release code, but not the major version.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (found ? SA_AIS_OK : SA_AIS_ERR_VERSION);
|
||||
|
||||
/*
|
||||
* If we fall out of the if loop, the caller requires a release code
|
||||
* beyond what we support.
|
||||
*/
|
||||
if (i == versionDatabase->versionCount) {
|
||||
i = versionDatabase->versionCount - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the caller what we support
|
||||
*/
|
||||
memcpy(version, &versionDatabase->versionsSupported[i], sizeof(*version));
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,7 +153,7 @@ saHandleInstancePut (
|
||||
SaErrorT
|
||||
saVersionVerify (
|
||||
struct saVersionDatabase *versionDatabase,
|
||||
const SaVersionT *version);
|
||||
SaVersionT *version);
|
||||
|
||||
SaErrorT
|
||||
saQueueInit (
|
||||
@ -188,3 +188,4 @@ SaTimeT
|
||||
clustTimeNow(void);
|
||||
|
||||
#endif /* AIS_UTIL_H_DEFINED */
|
||||
|
||||
|
@ -83,13 +83,10 @@ void testresult (SaAisErrorT result, SaAisErrorT expected, int test_no)
|
||||
}
|
||||
|
||||
SaVersionT version1 = { 'B', 0x01, 0x01 };
|
||||
SaVersionT version2 = { 'b', 0x01, 0x01 };
|
||||
SaVersionT version3 = { 'c', 0x01, 0x01 };
|
||||
SaVersionT version4 = { 'b', 0x02, 0x01 };
|
||||
SaVersionT version5 = { 'b', 0xff, 0x01 };
|
||||
SaVersionT version6 = { 'b', 0x01, 0xff };
|
||||
SaVersionT version7 = { 'B', 0xff, 0xff };
|
||||
SaVersionT version8 = { 'C', 0xff, 0xff };
|
||||
SaVersionT version2 = { 'A', 0x01, 0x01 };
|
||||
SaVersionT version3 = { 'B', 0x02, 0x01 };
|
||||
SaVersionT version4 = { 'B', 0x01, 0xff };
|
||||
SaVersionT version5 = { 'C', 0xff, 0xff };
|
||||
|
||||
struct version_test {
|
||||
SaVersionT *version;
|
||||
@ -98,11 +95,11 @@ struct version_test {
|
||||
|
||||
struct version_test versions[] = {
|
||||
{ &version1, SA_AIS_OK },
|
||||
{ &version2, SA_AIS_OK },
|
||||
{ &version2, SA_AIS_ERR_VERSION },
|
||||
{ &version3, SA_AIS_ERR_VERSION },
|
||||
{ &version4, SA_AIS_ERR_VERSION},
|
||||
{ &version8, SA_AIS_ERR_VERSION},
|
||||
{ 0, SA_AIS_ERR_VERSION}
|
||||
{ &version4, SA_AIS_OK},
|
||||
{ &version5, SA_AIS_ERR_VERSION},
|
||||
{ 0, SA_AIS_ERR_INVALID_PARAM}
|
||||
};
|
||||
|
||||
int version_size = sizeof(versions) / sizeof(struct version_test);
|
||||
|
Loading…
Reference in New Issue
Block a user