msg: Make msg_pre_send() and msg_post_recv() symmetrical
Since commit 7fe69e7ba0c3bdce88d3a89d5ed43d0b382ef022 management messages are dropped in some cases because the tlv_count isn't 1. Further analysis shows that this is the case when the message is forwarded in clock_forward_mgmt_msg(). This is because msg_post_recv() will append TLVs and - in the forwarding case - there is already one TLV in the list, which results in tlv_count being 2 and thus dropped in subsequent code. msg_post_recv() is intended to be the cleanup code for msg_pre_send() which is called earlier. Therefore, make msg_post_recv() and msg_pre_send() symmetrical and cleanup the tlv_list and tlv_count. Signed-off-by: Michael Walle <michael@walle.cc>
This commit is contained in:
parent
f977a653e0
commit
427f1b3981
18
msg.c
18
msg.c
@ -174,6 +174,16 @@ static struct tlv_extra *msg_tlv_prepare(struct ptp_message *msg, int length)
|
|||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void msg_tlv_recycle(struct ptp_message *msg)
|
||||||
|
{
|
||||||
|
struct tlv_extra *extra;
|
||||||
|
|
||||||
|
while ((extra = TAILQ_FIRST(&msg->tlv_list)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&msg->tlv_list, extra, list);
|
||||||
|
tlv_extra_recycle(extra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void port_id_post_recv(struct PortIdentity *pid)
|
static void port_id_post_recv(struct PortIdentity *pid)
|
||||||
{
|
{
|
||||||
pid->portNumber = ntohs(pid->portNumber);
|
pid->portNumber = ntohs(pid->portNumber);
|
||||||
@ -235,6 +245,7 @@ static void suffix_pre_send(struct ptp_message *msg)
|
|||||||
tlv->type = htons(tlv->type);
|
tlv->type = htons(tlv->type);
|
||||||
tlv->length = htons(tlv->length);
|
tlv->length = htons(tlv->length);
|
||||||
}
|
}
|
||||||
|
msg_tlv_recycle(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timestamp_post_recv(struct ptp_message *m, struct Timestamp *ts)
|
static void timestamp_post_recv(struct ptp_message *m, struct Timestamp *ts)
|
||||||
@ -561,18 +572,13 @@ void msg_print(struct ptp_message *m, FILE *fp)
|
|||||||
|
|
||||||
void msg_put(struct ptp_message *m)
|
void msg_put(struct ptp_message *m)
|
||||||
{
|
{
|
||||||
struct tlv_extra *extra;
|
|
||||||
|
|
||||||
m->refcnt--;
|
m->refcnt--;
|
||||||
if (m->refcnt) {
|
if (m->refcnt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pool_stats.count++;
|
pool_stats.count++;
|
||||||
pool_debug("recycle", m);
|
pool_debug("recycle", m);
|
||||||
while ((extra = TAILQ_FIRST(&m->tlv_list)) != NULL) {
|
msg_tlv_recycle(m);
|
||||||
TAILQ_REMOVE(&m->tlv_list, extra, list);
|
|
||||||
tlv_extra_recycle(extra);
|
|
||||||
}
|
|
||||||
TAILQ_INSERT_HEAD(&msg_pool, m, list);
|
TAILQ_INSERT_HEAD(&msg_pool, m, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user