4 ms·
If you close your files without waiting for fsync to return first, do you really care if the data has hit the disk? If fsync didn't fail, but close fails, what
by eptcyka 5y ago
If you close your files without waiting for fsync to return first, do you really care if the data has hit the disk? If fsync didn't fail, but close fails, what can you do then? Calling close() doesn't imply anything about flushing buffers or syncing data to disk or anything like that. It's just a signal to the OS that your process is done with this particular resource.
- CraigJPerry 5y agoYou should probably notify the user though
- eptcyka 5y agoIt depends. Regardless, it seems like Go will close file handles for you too, if you've not done it yet, in the finalizer code.
- ilammy 5y agoAlso, even if close() fails, you can no longer use the file descriptor anyway, since it might be already reused. The only thing you should do with the error from close() is log it to diagnose why it happened and prevent it next time.