[evolution-patches] camel-uid-cache.c robustness patch
- From: Jeffrey Stedfast <fejj ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] camel-uid-cache.c robustness patch
- Date: 03 Jun 2003 15:14:37 -0400
Attached patch makes the uid cache code more robust wrt handling
read/write errors by using the camel-io functions.
Jeff
--
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com - www.ximian.com
? 43406-again.patch
? ChangeLog.nonximian
? body
? body.c
? body.txt
? camel-mime-filter-windows.c
? camel-mime-filter-windows.h
? charset-map.c
? charset-map.diff
? cmsutil.c
? date.patch
? debug.patch
? ehlo.patch
? evolution-1.3-gpg.patch
? folder-info-build.patch
? foo
? html-filter-broken.msg
? imap
? invalid-content-id.patch
? iso
? iso.c
? pop3-uidl.patch
? smime
? uid-cache.patch
? win-charset.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1823
diff -u -r1.1823 ChangeLog
--- ChangeLog 1 Jun 2003 23:49:27 -0000 1.1823
+++ ChangeLog 3 Jun 2003 18:57:58 -0000
@@ -1,3 +1,11 @@
+2003-06-03 Jeffrey Stedfast <fejj ximian com>
+
+ * camel-uid-cache.c (camel_uid_cache_new): Don't create the cache
+ file as 0700 (wtf? why the x attr?), create it with 0600
+ instead. Also use camel-io's read() function so that we get error
+ handling for free.
+ (maybe_write_uid): Use camel_write() here to make it more robust.
+
2003-06-01 Jeffrey Stedfast <fejj ximian com>
* broken-date-parser.c (d): Turn off debugging.
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/camel/Makefile.am,v
retrieving revision 1.182
diff -u -r1.182 Makefile.am
--- Makefile.am 30 Apr 2003 15:35:28 -0000 1.182
+++ Makefile.am 3 Jun 2003 18:57:58 -0000
@@ -49,6 +49,7 @@
camel-http-stream.c \
camel-index.c \
camel-internet-address.c \
+ camel-io.c \
camel-lock.c \
camel-lock-client.c \
camel-medium.c \
@@ -150,6 +151,7 @@
camel-http-stream.h \
camel-index.h \
camel-internet-address.h \
+ camel-io.h \
camel-i18n.h \
camel-lock.h \
camel-lock-client.h \
Index: camel-io.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-io.c,v
retrieving revision 1.1
diff -u -r1.1 camel-io.c
--- camel-io.c 3 Mar 2003 22:53:15 -0000 1.1
+++ camel-io.c 3 Jun 2003 18:57:58 -0000
@@ -35,6 +35,10 @@
#include "camel-operation.h"
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
/* FIXME: should we trade out select() for a poll() instead? */
ssize_t
Index: camel-uid-cache.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-uid-cache.c,v
retrieving revision 1.10
diff -u -r1.10 camel-uid-cache.c
--- camel-uid-cache.c 2 Nov 2002 00:42:07 -0000 1.10
+++ camel-uid-cache.c 3 Jun 2003 18:57:58 -0000
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <unistd.h>
+#include "camel-io.h"
#include "camel-uid-cache.h"
struct _uid_state {
@@ -89,7 +90,7 @@
mkdir_heir (dirname, 0700);
g_free (dirname);
- fd = open (filename, O_RDWR | O_CREAT, 0700);
+ fd = open (filename, O_RDWR | O_CREAT, 0600);
if (fd == -1)
return NULL;
@@ -99,7 +100,7 @@
}
buf = g_malloc (st.st_size + 1);
- if (read (fd, buf, st.st_size) == -1) {
+ if (st.st_size > 0 && camel_read (fd, buf, st.st_size) == -1) {
close (fd);
g_free (buf);
return NULL;
@@ -113,16 +114,19 @@
uids = g_strsplit (buf, "\n", 0);
g_free (buf);
- for (i = 0; uids[i]; i++) {
- struct _uid_state *state;
-
- state = g_new (struct _uid_state, 1);
- state->level = cache->level;
- state->save = TRUE;
+ if (uids != NULL) {
+ for (i = 0; uids[i]; i++) {
+ struct _uid_state *state;
+
+ state = g_new (struct _uid_state, 1);
+ state->level = cache->level;
+ state->save = TRUE;
+
+ g_hash_table_insert (cache->uids, uids[i], state);
+ }
- g_hash_table_insert (cache->uids, uids[i], state);
+ g_free (uids);
}
- g_free (uids);
return cache;
}
@@ -150,9 +154,10 @@
CamelUIDCache *cache = data;
struct _uid_state *state = value;
+ /* FIXME: what should we do if a write() fails? abort? or what? */
if (state && state->level == cache->level && state->save) {
- write (cache->fd, key, strlen (key));
- write (cache->fd, "\n", 1);
+ camel_write (cache->fd, key, strlen (key));
+ camel_write (cache->fd, "\n", 1);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]