mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
util: *DO NOT* loop for EINTR handling with close_nointr()
See the linked references for why we should not do this.
This commit is contained in:
parent
2a2473d89e
commit
b0ee8068da
@ -183,18 +183,25 @@ bool first_word(const char *s, const char *word) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int close_nointr(int fd) {
|
int close_nointr(int fd) {
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
|
r = close(fd);
|
||||||
|
|
||||||
for (;;) {
|
/* Just ignore EINTR; a retry loop is the wrong
|
||||||
int r;
|
* thing to do on Linux.
|
||||||
|
*
|
||||||
r = close(fd);
|
* http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
|
||||||
if (r >= 0)
|
* https://bugzilla.gnome.org/show_bug.cgi?id=682819
|
||||||
return r;
|
* http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
|
||||||
|
* https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
|
||||||
if (errno != EINTR)
|
*/
|
||||||
return -errno;
|
if (_unlikely_(r < 0 && errno == EINTR))
|
||||||
}
|
return 0;
|
||||||
|
else if (r >= 0)
|
||||||
|
return r;
|
||||||
|
else
|
||||||
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_nointr_nofail(int fd) {
|
void close_nointr_nofail(int fd) {
|
||||||
|
Loading…
Reference in New Issue
Block a user