FreeBSD takes the lock for the global FILE* list in fclose around where it
sets _flags to 0. OpenBSD doesn't (though it does take the lock around the
corresponding read in __sfp) which seems like a bug.
i'm curious how attached you are to __sfp and moreglue though. the non-BSD
C libraries seem to have given up on this, and it does seem like a
questionable "optimization" for this day and age. (especially since there's
neither a bound to the pool nor any eviction policy, not to mention the
need to contend on the lock.)
i'm happy to experiment in Android, but i'm curious to know whether
upstream would want any such changes...
--elliott (for my own reference: internal bug 17154680.)