Index: filed.c ================================================================== --- filed.c +++ filed.c @@ -997,10 +997,13 @@ * We have to make a duplicate FD, because once we release the cache * mutex, the file descriptor may be closed */ fd = dup(cache->fd); if (fd < 0) { + close(cache->fd); + cache->fd = -1; + pthread_mutex_unlock(&cache->mutex); return(NULL); }