Andrey, I would note that in general list comprehensions are a bit
dangerous besides mapping they also allow filtering.
If that code was written as:
lists:foreach(
fun({_, {Pid, _LruTime}}) -> couch_util:shutdown_sync(Pid) end,
ets:tab2list(couch_dbs_by_name))
We would have noticed before the bug, as it would generate a
function_clause error/exception. Notice here we don't care about the
resulting list, so a lists:foreach is the way to go.
On Wed, Jun 15, 2011 at 10:47 AM, Filipe David Manana
<[email protected]> wrote:
> It seems to me you're right about it.
>
> Do you want to provide a small patch to fix it? (Ideally in a Jira ticket)
>
> Thanks Andrey
>
>
> On Wed, Jun 15, 2011 at 10:30 AM, Andrey Somov
> <[email protected]> wrote:
>> Hi all,
>> when I read the code in couch_server.terminate() function I see the
>> following in the trunk:
>>
>> terminate(_Reason, _Srv) ->
>> [couch_util:shutdown_sync(Pid) || {_, {Pid, _LruTime}} <-
>> ets:tab2list(couch_dbs_by_name)],
>> ok.
>>
>> It looks like the values in the couch_dbs_by_name table are tuples of 2
>> terms.
>> But when I read the rest of the code I see that the values are always
>> 3-term-tuples:
>>
>> {opened, Pid, LruTime} or {opening, Opener, [Froms]}
>>
>> I must admit I do not understand how the code in the terminate() may work.
>> Is it just a bug ?
>>
>>
>> -
>> Andrey
>>
>
>
>
> --
> Filipe David Manana,
> [email protected], [email protected]
>
> "Reasonable men adapt themselves to the world.
> Unreasonable men adapt the world to themselves.
> That's why all progress depends on unreasonable men."
>
--
Filipe David Manana,
[email protected], [email protected]
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."