uwiger / gproc

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

Re-adding a worker to a pool #59

Closed jur0 closed 10 years ago

jur0 commented 10 years ago

When a worker is added to an empty pool, deleted from the pool and then added again, there is an issue with gproc:get_value/2 in https://github.com/uwiger/gproc/blob/master/src/gproc_pool.erl#L613 as a tuple is expected. Instead of {0, round_robin} just 0 is returned.

1> application:start(gproc).
ok
2> {ok, P1} = srv:start_link().
{ok,<0.43.0>}
3> gproc:reg({n,l,"x"},P1).
true
4> gproc_pool:new("pool").
ok
5> gproc:get_value({p, l, {gproc_pool, "pool"}}, shared).
{0,round_robin}
6> gproc_pool:add_worker("pool","x").
1
7> gproc_pool:connect_worker("pool", "x").
true
8> gproc:get_value({p, l, {gproc_pool, "pool"}}, shared).
{1,round_robin}
9> gproc_pool:disconnect_worker("pool", "x").
true
10> gproc_pool:remove_worker("pool","x").
true
11> gproc_pool:add_worker("pool","x").
server backtrace: [{gproc_pool,add_worker_,2,
                               [{file,"src/gproc_pool.erl"},{line,613}]},
                   {gproc_pool,handle_call_,3,
                               [{file,"src/gproc_pool.erl"},{line,510}]},
                   {gproc_pool,handle_call,3,
                               [{file,"src/gproc_pool.erl"},{line,493}]},
                   {gen_server,handle_msg,5,
                               [{file,"gen_server.erl"},{line,585}]},
                   {proc_lib,init_p_do_apply,3,
                             [{file,"proc_lib.erl"},{line,239}]}]
** exception error: no match of right hand side value 0
     in function  gproc_pool:call/1 (src/gproc_pool.erl, line 483)
12> gproc:get_value({p, l, {gproc_pool, "pool"}}, shared).
0
uwiger commented 10 years ago

Could you check out PR #60 ?

jur0 commented 10 years ago

I've checked that and it's working now. I think it could be merged.

uwiger commented 10 years ago

Ok, thanks. Merged.