return set_put(MAKE_SET(s), FD_TO_PTR(fd));
}
+int fdset_consume(FDSet *s, int fd) {
+ int r;
+
+ assert(s);
+ assert(fd >= 0);
+
+ r = fdset_put(s, fd);
+ if (r < 0)
+ safe_close(fd);
+
+ return r;
+}
+
int fdset_put_dup(FDSet *s, int fd) {
_cleanup_close_ int copy = -EBADF;
int r;
FDSet* fdset_free(FDSet *s);
int fdset_put(FDSet *s, int fd);
+int fdset_consume(FDSet *s, int fd);
int fdset_put_dup(FDSet *s, int fd);
bool fdset_contains(FDSet *s, int fd);
if (fd < 0)
return fd;
- r = fdset_put(fds, fd);
+ r = fdset_consume(fds, TAKE_FD(fd));
if (r < 0)
return log_oom();
-
- TAKE_FD(fd);
}
}