bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: race condition in libports


From: Brent W. Baccala
Subject: Re: race condition in libports
Date: Fri, 5 Jan 2018 19:47:37 -0500

On Fri, Jan 5, 2018 at 7:24 PM, Samuel Thibault <samuel.thibault@gnu.org> wrote:
Hello,

Brent W. Baccala, on ven. 05 janv. 2018 17:45:57 -0500, wrote:
> I've "fixed" this by making sure we don't remove the hash table entry unless
> there are exactly two weak references outstanding, but I'm not sure that's the
> best way to handle it.  It doesn't seem like the dropweak routine should have
> to be so careful; it shouldn't get called twice like that.

Well, AIUI from the documentation, dropweak should manage by itself how
many weak references it should drop. I.e. the number of times dropweak
is called doesn't matter, the first call should drop them, and later
calls should be fine that there aren't any to drop any more. So it seems
to me that your proposed fix is correct. I just rewrote it to make sure
to get coherent counts between hard and weak.

Well, in that case, perhaps it should work by checking to see if the port is in the hash, rather than by looking at how many weak references it's got.  Something more like this:

  if ((refcounts_hard_references(&i->pi.refcounts) == 0)
      && (* i->id_hashloc == i))
    {
      /* Nobody got a send right in between, we can remove from the hash.  */
      hurd_ihash_locp_remove (&idhash, i->id_hashloc);
      ports_port_deref_weak (&i->pi);
    }

Also, what documentation?  The hurd texinfo file?  That's the only place that I know of where this is documented.

    agape
    brent



 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]