In the lwm2m demo project, the function prv_register() is used to send the registration for a single server. However, the function transaction_send(), which is called by the function prv_register() to perform send operation, will cause retransfer due to the fact that the time do not reach the first second in some reboot occasion as shown in the https://gitee.com/LiteOS/LiteOS/blob/master/components/connectivity/lwm2m/core/transaction.c?_from=gitee_search#L446. The variable tv_sec may be zero if just reboot and still in the time of the first second.
And I'm not sure why this time judgment is needed.
Build and run lwm2m. Please pay attention that the occasion is not always could be observed.
No errors. But the process and the performance will be affected.
@SilentDawn
The variable tv_sec may be zero if just reboot and still in the time of the first second.
And I'm not sure why this time judgment is needed.
Yes, when client device has rebooted, the tv_sec must be zero.
In the registration process, the first time ack_received is null:
if (!transacP->ack_received)
{
long unsigned timeout = 0;
if (0 == transacP->retrans_counter) --> and we are here, the retrans_counter is zero
{
time_t tv_sec = lwm2m_gettime(); --> get local devie time(s)
if (tv_sec) --> if tv_sec >= 1, set the counter flag retrans_counter
{
transacP->retrans_time = tv_sec + COAP_RESPONSE_TIMEOUT;
transacP->retrans_counter = 1;
timeout = 0;
}
else --> if tv_sec < 1, do not set counter flag
{
maxRetriesReached = true;
}
if (COAP_MAX_RETRANSMIT + 1 >= transacP->retrans_counter)
{
ret = lwm2m_buffer_send(transacP->peerH, transacP->buffer, transacP->buffer_len, contextP->userData); --> try to send again
output_buffer(stderr, (uint8_t *)(transacP->buffer), transacP->buffer_len, 0);
transacP->retrans_time += timeout;
LOG_ARG("send result is %d, retrans_counter:%d", ret, transacP->retrans_counter);
transacP->retrans_counter += 1; --> set counter flag here,when retrans_counter is zero, the next time will not go to branch:if (0 == transacP->retrans_counter)
UNUSEX(ret);
}
It is obviously that, when tv_sec < 1, there is no problem; but if when tv_sec > 1, set retrans_time for transaction_step to remove some transcation from linked list.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论