[Libwebsockets] Multi-tail ring-buffer's oldest_tail issue

Ariel D'Alessandro ariel at vanguardiasur.com.ar
Tue Nov 27 15:08:45 CET 2018


Andy,

On 11/27/18 10:49 AM, Andy Green wrote:
> It's a bug in that particular minimal example... the most evolved,
> hammered and commented user of lws_ring is the mirror plugin, the corner
> case you noticed is handled fine there:
> 
>     case LWS_CALLBACK_CLOSED:
>         /* detach our pss from the mirror instance */
>         mi = pss->mi;
>         if (!mi)
>             break;
> 
>         lws_pthread_mutex_lock(&v->lock); /* vhost lock { */
> 
>         /* remove our closing pss from its mirror instance list */
>         lws_ll_fwd_remove(struct per_session_data__lws_mirror,
>                   same_mi_pss_list, pss, mi->same_mi_pss_list);
>         pss->mi = NULL;
> 
>         if (mi->same_mi_pss_list) {
>             /*
>              * Still other pss using the mirror instance.  The pss
>              * going away may have had the oldest tail, reconfirm
>              * using the remaining pss what is the current oldest
>              * tail.  If the oldest tail moves on, this call also
>              * will re-enable rx flow control when appropriate.
>              */
>             lws_pthread_mutex_lock(&mi->lock); /* mi lock { */
>             __mirror_update_worst_tail(mi);
>             lws_pthread_mutex_unlock(&mi->lock); /* } mi lock */
>             lws_pthread_mutex_unlock(&v->lock); /* } vhost lock */
>             break;
>         }
> ...
> 
> https://libwebsockets.org/git/libwebsockets/tree/plugins/protocol_lws_mirror.c#n285-311
> 
> 
> It's not that lws_ring itself misses the trick, it's just very difficult
> to keep 50+ minimal examples synchronized with everything.

Right. Cool, thanks for pointing out the right implementation. I just
missed this example and wanted to be sure on the right way to handle this.

Thanks again for the quick response.

-- 
Ariel D'Alessandro, VanguardiaSur
www.vanguardiasur.com.ar


More information about the Libwebsockets mailing list