uwiger / gproc

Extended process registry for Erlang
Apache License 2.0
1.07k stars 232 forks source link

Fixed case when waiter is the same process as one being registered #7

Closed idubrov closed 13 years ago

idubrov commented 13 years ago

Consider the following commands given in the shell:

application:start(gproc). gproc:nb_wait({n, l, somekey}). gproc:reg({n, l, somekey}). gproc:unreg({n, l, somekey}).

This will fail, because gproc:maybe_waiters firstly inserts key in the ETS ({{<0.43.0>,{n,l,somekey}},r}), then invokes notify_waiters which in turn removes the same row from the ETS (since the waiting and registering processes are the same). The patch simply changes the order of two invocations. Firstly it notifies the waiters, then it inserts the row into the ETS.

uwiger commented 13 years ago

Thanks. I have implemented a slightly different fix in https://github.com/esl/gproc/tree/v0.2.8

I keep the esl version more current, and only occasionally push to the uwiger version.