[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: dangerous hash usage?

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-09-25 00:37:00 CEST

Ben Collins-Sussman wrote:
> Ben Collins-Sussman <sussman@collab.net> writes:
>
>>Working on #1075, I noticed this:
>>
>>I see code in svn which loops over an apr_hash_t, yet code within the
>>loop potentially removes an item from the hash. Isn't this
>>dangrerous? Can't this mess up the hash iterator (apr_hash_index_t)?
>>
>>In particular, I'm looking at libsvn_wc/adm_ops.c:121.
>
> Hm, I shoulda checked the APR docs. They say:
>
> * @remark There is no restriction on adding or deleting hash entries during
> * an iteration (although the results may be unpredictable unless all you do
> * is delete the current entry) and multiple iterations can be in
> * progress at the same time.

That's a confusing @remark. I would suggest it be changed to one of these if one of these is correct:

 * @remark During an iteration it is safe to delete the current hash entry,
 * but not to delete any other entry or to add an entry.
 * Multiple iterations may be in progress at the same time if none of them
 * adds or deletes hash entries.

 * @remark During an iteration it is safe to delete the current hash entry,
 * and to add entries.
 * Multiple iterations may be in progress at the same time if none of them
 * deletes hash entries.

I.e. the remark should say what is guaranteed to be safe, not "you may do this but the results may be unpredictable".

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Sep 25 00:38:36 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.