mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
Introduce VIR_CLOSE to be used rather than close()
Since bugs due to double-closed file descriptors are difficult to track down in a multi-threaded system, I am introducing the VIR_CLOSE(fd) macro to help avoid mistakes here. There are lots of places where close() is being used. In this patch I am only cleaning up usage of close() in src/conf where the problems were. I also dare to declare close() as being deprecated in libvirt code base (HACKING).
This commit is contained in:
@@ -318,6 +318,23 @@ routines, use the macros from memory.h
|
||||
VIR_FREE(domain);
|
||||
|
||||
|
||||
File handling
|
||||
=============
|
||||
|
||||
Use of the close() API is deprecated in libvirt code base to help avoiding
|
||||
double-closing of a file descriptor. Instead of this API, use the macro from
|
||||
files.h
|
||||
|
||||
- eg close a file descriptor
|
||||
|
||||
if (VIR_CLOSE(fd) < 0) {
|
||||
virReportSystemError(errno, _("failed to close file"));
|
||||
}
|
||||
|
||||
- eg close a file descriptor in an error path, without losing the previous
|
||||
errno value
|
||||
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
|
||||
String comparisons
|
||||
==================
|
||||
|
||||
Reference in New Issue
Block a user