On Thu, Jul 05, 2018 at 09:46:26AM +0200, Michael Walle wrote:

> @@ -193,6 +193,8 @@ static int suffix_post_recv(struct ptp_message *msg, int 
> len)
>       if (!ptr)
>               return 0;
>  
> +     msg_tlv_recycle(msg);
> +

Although this fixes the issue, still it is not symmetric.  The TLV
list is built during suffix_post_recv(), and so it should be taken
down during suffix_pre_send().

> @@ -561,18 +575,13 @@ void msg_print(struct ptp_message *m, FILE *fp)
>  
>  void msg_put(struct ptp_message *m)
>  {
> -     struct tlv_extra *extra;
> -
>       m->refcnt--;
>       if (m->refcnt) {
>               return;
>       }
>       pool_stats.count++;
>       pool_debug("recycle", m);
> -     while ((extra = TAILQ_FIRST(&m->tlv_list)) != NULL) {
> -             TAILQ_REMOVE(&m->tlv_list, extra, list);
> -             tlv_extra_recycle(extra);
> -     }
> +     msg_tlv_recycle(m);

The re-factoring is okay, but...

>       TAILQ_INSERT_HEAD(&msg_pool, m, list);
>  }
>  
> diff --git a/msg.h b/msg.h
> index 58a916c..6a3509b 100644
> --- a/msg.h
> +++ b/msg.h
> @@ -280,6 +280,13 @@ struct tlv_extra *msg_tlv_append(struct ptp_message 
> *msg, int length);
>  void msg_tlv_attach(struct ptp_message *msg, struct tlv_extra *extra);
>  
>  /**
> + * Drop all TLVs of a message.
> + *
> + * @param msg     A message obtained using msg_allocate().
> + */
> +void msg_tlv_recycle(struct ptp_message *msg);

No need for a global function.  The only callers are in msg.c, and so
the helper function needs the 'static' keyword.

Thanks,
Richard

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to