是否存在c->ping_outstanding = 1;的后一秒就触发TimerIsExpired(&c->last_received)
int keepalive(MQTTClient *c)
{
int rc = SUCCESS;
if (c->keepAliveInterval == 0)
goto exit;
if (TimerIsExpired(&c->last_sent) || TimerIsExpired(&c->last_received))
{
if (c->ping_outstanding)
rc = FAILURE; /* PINGRESP not received in keepalive interval */
else
{
Timer timer;
TimerInit(&timer);
TimerCountdownMS(&timer, 1000);
int len = MQTTSerialize_pingreq(c->buf, c->buf_size);
if (len > 0 && (rc = sendPacket(c, len, &timer)) == SUCCESS) // send the ping packet
c->ping_outstanding = 1;
}
}
exit:
return rc;
}