[gmime] Simplified GMimeStreamFs and GMimeStreamMmap close()
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Simplified GMimeStreamFs and GMimeStreamMmap close()
- Date: Wed, 20 Dec 2017 17:12:08 +0000 (UTC)
commit b0d5531bee6b24f1e8093c6e749d165ba3475afb
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Sat Dec 16 16:34:22 2017 -0500
Simplified GMimeStreamFs and GMimeStreamMmap close()
gmime/gmime-stream-fs.c | 9 ++++-----
gmime/gmime-stream-mmap.c | 15 +++++++++------
2 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/gmime/gmime-stream-fs.c b/gmime/gmime-stream-fs.c
index 7ded4b0..ad7e8eb 100644
--- a/gmime/gmime-stream-fs.c
+++ b/gmime/gmime-stream-fs.c
@@ -240,7 +240,7 @@ static int
stream_close (GMimeStream *stream)
{
GMimeStreamFs *fs = (GMimeStreamFs *) stream;
- int rv;
+ int rv = 0;
if (fs->fd == -1)
return 0;
@@ -248,13 +248,12 @@ stream_close (GMimeStream *stream)
if (fs->owner) {
do {
if ((rv = close (fs->fd)) == 0)
- fs->fd = -1;
+ break;
} while (rv == -1 && errno == EINTR);
- } else {
- fs->fd = -1;
- rv = 0;
}
+ fs->fd = -1;
+
return rv;
}
diff --git a/gmime/gmime-stream-mmap.c b/gmime/gmime-stream-mmap.c
index 8272d57..048800e 100644
--- a/gmime/gmime-stream-mmap.c
+++ b/gmime/gmime-stream-mmap.c
@@ -226,20 +226,23 @@ stream_close (GMimeStream *stream)
GMimeStreamMmap *mm = (GMimeStreamMmap *) stream;
int rv = 0;
- if (mm->map) {
+ if (mm->fd == -1)
+ return 0;
+
+ if (mm->owner) {
#ifdef HAVE_MUNMAP
munmap (mm->map, mm->maplen);
- mm->map = NULL;
#endif
- }
-
- if (mm->owner && mm->fd != -1) {
+
do {
if ((rv = close (mm->fd)) == 0)
- mm->fd = -1;
+ break;
} while (rv == -1 && errno == EINTR);
}
+ mm->map = NULL;
+ mm->fd = -1;
+
return rv;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]