[Rpm-maint] [rpm-software-management/rpm] Add macro to force fsync() on close() (#187)

Panu Matilainen notifications at github.com
Wed Apr 5 05:28:20 UTC 2017


pmatilai commented on this pull request.



> +    int rc = 0, ec = 0;
+
+    if (fd == NULL)
+	return -1;
+
+    fd = fdLink(fd);
+    for (FDSTACK_t fps = fd->fps; fps != NULL; fps = fps->prev) {
+	if (fps->fdno >= 0) {
+            rc = fsync(fps->fdno);
+	    if (ec == 0 && rc)
+		ec = rc;
+	}
+
+	/* Leave freeing the last one after stats */
+	if (fps->prev == NULL)
+	    break;

This condition is quite clearly a leftover from copy-pasting Fclose(). It's probably not harmful to the cause here but it's also unnecessary and the comment is just plain wrong in this context.
The also copy-pasted fdLink() earlier is more harmful, it'll cause a file descriptor (and memory) leak since it's incrementing the reference count without ever decrementing it. 

These were kinda implied between the lines in the "just walk fps->prev" (instead of using copy-pasted Fclose code), sorry for not being more clear about it.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/187#pullrequestreview-30958967
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170404/fa93d0fc/attachment.html>


More information about the Rpm-maint mailing list