I know that the refcount of 2 is caused by the two ad_open() in afp_openfork() and the corresponding afp_closefork() only does one call to a_close() (through of_closefork()).

Apart from that, I tried to report this as a bug only with ample information to reproduce it, only to be told that appledouble = v2 is unsupported and I could try patching it myself, maybe.  Since this is a serious issue for me (the server becomes unusable because it has exhausted all available file descriptors after about a day of light usage) I did come up with a patch that works in all cases and fixes my problems.

If you feel that this is not the correct solution, feel free to investgate and come up with a different patch.  I have a bug report at sourceforge here: https://sourceforge.net/p/netatalk/bugs/554/ that contains reproduction infor along with a debug log of me playing around in a folder with images for about 3 minutes leading to a leak of 300+ files descriptors.

In the meantime, I will be keeping this patch locally in order to have a usable server.