I pushed to Gerrit a new patch set with limited ambitions:
1. It repairs almost all of the myriad style issues that Sudarshan
pointed out.
2. It provides replacement code for filtering address family duplicates.
The original code worked until the last rebase, and then its timing sensitivity
became apparent, meaning it didn't work reliably. This is the code described
in our IPv6 document for ocstack.c::HandleStackRequests. I replaced that code
with code in camessagehandler.c
/*
* If a second message arrives with the same token and the other address
* family, drop it. Typically, IPv6 beats IPv4, so the IPv4 message is dropped.
* This can be made more robust, but the current code is good enough for now.
*/
CABool_t CADropLosingAddressFamily(CABool_t isRequest, CAToken_t *token,
CAConnectivityType_t type)
{
static CAToken_t reqToken = {0}, resToken = {0};
static CAConnectivityType_t reqType, resType;
CABool_t ret = FALSE;
CAToken_t *t;
CAConnectivityType_t *c;
if (isRequest) {
t = &reqToken;
c = &reqType;
} else {
t = &resToken;
c = &resType;
}
if (memcmp(t, token, CA_MAX_TOKEN_LEN) == 0) {
if (((type ^ *c) & ADDR_FAMILY_MODS_MASK) == ADDR_FAMILY_MODS_MASK) {
if (type & CA_IPv6) {
OIC_LOG(INFO, TAG, PCF("IPv6 duplicate response ignored"));
} else {
OIC_LOG(INFO, TAG, PCF("IPv4 duplicate response ignored"));
}
ret = TRUE;
}
}
memcpy(t, token, CA_MAX_TOKEN_LEN);
*c = type;
return ret;
}
(Don't worry: the committed code follows coding guidelines.)
This function is called in both the request and response paths, so it is more
effective at eliminating the redundant messages, and it is performed before one
of the queues, so it is less timing dependent. As commented, this is not the
final solution to this issue, but points in the direction of one.
We appreciate the wide range of comments on the ca-ipv6 branch. If you
appreciate the ability to review architectural changes long before they reach
the code, we hope you will submit your early changes when you next contribute.
John Light
Intel Opensource Technology Center OIC Development
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20150320/eb99da7e/attachment.html>