On May 31, 2014, at 12:05 PM, Sebastian Lackner wrote:
> Changes in try 2:
>
> * Always try to access the fd cache two times - this ensures that we
> don't release a file descriptor when its still in use by a second thread.
Heh. Well, you can ignore that part of my reply to your previous try. :)
> * Replace interlocked_xchg() with an assert(). The original code looks
> like its valid that the fd is nonzero at this point, but in fact this
> would cause releasing a file descriptor which is still in use.
I'll leave it to others to comment on that.
> Replacing with an assert() also saves a couple of CPU cycles.
I understand that this is an attempt to improve performance, but I don't think it's necessary to squeeze every last CPU cycle out of this code.
-Ken