aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-09-11 05:39:56 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-09-11 05:39:56 +0800
commit75e84ec74f0eaf6ffd7d865478e170f084f2ff63 (patch)
treed9698160e23dc0ba86157301e67f77c458d43214 /camel
parentfbb7f7c202c6c4f8b435702ababe36463132292c (diff)
downloadgsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar.gz
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar.bz2
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar.lz
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar.xz
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.tar.zst
gsoc2013-evolution-75e84ec74f0eaf6ffd7d865478e170f084f2ff63.zip
Same as below. Also save errno before closing the file so our caller can
2002-09-10 Jeffrey Stedfast <fejj@ximian.com> * camel-store-summary.c (camel_store_summary_load): Same as below. Also save errno before closing the file so our caller can figure out why we failed. (camel_store_summary_save): Same here, but also flush the output stream to disk. * camel-folder-summary.c (camel_folder_summary_load): s/fclose(in) == -1/fclose(in) != 0/ since fclose doesn't necessarily return -1 on fail, all we really know is that it returns 0 on success and non-zero on fail. * camel-certdb.c (camel_certdb_save): fsync() the stream after we fflush it. svn path=/trunk/; revision=18037
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-certdb.c2
-rw-r--r--camel/camel-folder-summary.c3
-rw-r--r--camel/camel-store-summary.c21
4 files changed, 34 insertions, 6 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 198d071934..bc9fc2b303 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,19 @@
2002-09-10 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-store-summary.c (camel_store_summary_load): Same as
+ below. Also save errno before closing the file so our caller can
+ figure out why we failed.
+ (camel_store_summary_save): Same here, but also flush the output
+ stream to disk.
+
+ * camel-folder-summary.c (camel_folder_summary_load): s/fclose(in)
+ == -1/fclose(in) != 0/ since fclose doesn't necessarily return -1
+ on fail, all we really know is that it returns 0 on success and
+ non-zero on fail.
+
+ * camel-certdb.c (camel_certdb_save): fsync() the stream after we
+ fflush it.
+
* camel-folder-summary.c (perform_content_info_save): Do proper
error checking and return -1 on fail.
(camel_folder_summary_save): Check the return of
diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c
index 6b6b6c3d67..14020fec16 100644
--- a/camel/camel-certdb.c
+++ b/camel/camel-certdb.c
@@ -372,7 +372,7 @@ camel_certdb_save (CamelCertDB *certdb)
CAMEL_CERTDB_UNLOCK (certdb, io_lock);
- if (fflush (out) != 0) {
+ if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
i = errno;
fclose (out);
unlink (filename);
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 3ec6c93107..4eea17751a 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2000 Ximian Inc.
*
@@ -580,7 +581,7 @@ camel_folder_summary_load(CamelFolderSummary *s)
CAMEL_SUMMARY_UNLOCK(s, io_lock);
- if (fclose(in) == -1)
+ if (fclose (in) != 0)
return -1;
s->flags &= ~CAMEL_SUMMARY_DIRTY;
diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c
index b114ac78f4..fc839dfed7 100644
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@ -362,7 +362,7 @@ camel_store_summary_load(CamelStoreSummary *s)
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
- if (fclose(in) == -1)
+ if (fclose (in) != 0)
return -1;
s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
@@ -370,11 +370,13 @@ camel_store_summary_load(CamelStoreSummary *s)
return 0;
error:
+ i = ferror (in);
g_warning("Cannot load summary file: %s", strerror(ferror(in)));
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
fclose(in);
s->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
-
+ errno = i;
+
return -1;
}
@@ -412,8 +414,10 @@ camel_store_summary_save(CamelStoreSummary *s)
}
out = fdopen(fd, "w");
if ( out == NULL ) {
+ i = errno;
printf("** fdopen error: %s\n", strerror(errno));
close(fd);
+ errno = i;
return -1;
}
@@ -422,8 +426,10 @@ camel_store_summary_save(CamelStoreSummary *s)
CAMEL_STORE_SUMMARY_LOCK(s, io_lock);
if ( ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1) {
+ i = errno;
fclose(out);
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+ errno = i;
return -1;
}
@@ -438,8 +444,15 @@ camel_store_summary_save(CamelStoreSummary *s)
}
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
-
- if (fclose(out) == -1)
+
+ if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
+ i = errno;
+ fclose (out);
+ errno = i;
+ return -1;
+ }
+
+ if (fclose (out) != 0)
return -1;
s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;