aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog29
-rw-r--r--camel/camel-filter-driver.c6
-rw-r--r--camel/camel-mime-message.c11
-rw-r--r--camel/camel-mime-parser.c23
-rw-r--r--camel/camel-mime-parser.h3
-rw-r--r--camel/camel-mime-part.c10
-rw-r--r--camel/providers/local/camel-maildir-folder.c3
-rw-r--r--camel/providers/local/camel-mbox-folder.c3
-rw-r--r--camel/providers/local/camel-spool-folder.c3
9 files changed, 82 insertions, 9 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index d8ba0bc968..992e6c4009 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,32 @@
+2001-10-31 <NotZed@Ximian.com>
+
+ * providers/local/camel-spool-folder.c (spool_get_message): Same
+ as below.
+
+ * providers/local/camel-maildir-folder.c (maildir_get_message):
+ Same as below.
+
+ * providers/local/camel-mbox-folder.c (mbox_get_message): Set
+ USER_CANCEL if failed due to EINTR.
+
+ * camel-filter-driver.c (camel_filter_driver_filter_mbox): If
+ construct from parser fails due to user cancel, set USER_CANCEL on
+ exception.
+
+ * camel-mime-part.c (construct_from_parser): Return error if the
+ parser had an io error.
+
+ * camel-mime-message.c (construct_from_parser): Check error on
+ parser/return error.
+
+ * camel-mime-parser.c (folder_scan_init): Init error number.
+ (camel_mime_parser_errno): New function, return errno of any io
+ failures.
+ (folder_read): Set errno if a failure occured.
+ (folder_seek): Same.
+ (folder_scan_init_with_fd): Setup errno depeding on ok/failure.
+ (folder_scan_init_with_stream): Same.
+
2001-10-30 <NotZed@Ximian.com>
* camel-operation.c (camel_operation_new): Dont setup cancel_fd.
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 07216efb72..1b9c30efb6 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -29,6 +29,8 @@
#include <glib.h>
+#include <errno.h>
+
#include "camel-filter-driver.h"
#include "camel-filter-search.h"
@@ -687,8 +689,8 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co
msg = camel_mime_message_new ();
if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) {
+ camel_exception_set (ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM, _("Cannot open message"));
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot open message"));
camel_object_unref (CAMEL_OBJECT (msg));
goto fail;
}
@@ -715,7 +717,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co
if (p->defaultfolder) {
report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
- camel_folder_sync(p->defaultfolder, FALSE, ex);
+ camel_folder_sync(p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
}
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete"));
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 02ed187929..62d57bea70 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -33,6 +33,8 @@
#include <gal/util/e-iconv.h>
+#include <errno.h>
+
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include "camel-stream-mem.h"
@@ -453,6 +455,7 @@ construct_from_parser (CamelMimePart *dw, CamelMimeParser *mp)
int len;
int state;
int ret;
+ int err;
d(printf("constructing mime-message\n"));
@@ -481,7 +484,13 @@ construct_from_parser (CamelMimePart *dw, CamelMimeParser *mp)
#ifndef NO_WARNINGS
#warning "return a real error code"
#endif
- return 0;
+ err = camel_mime_parser_errno(mp);
+ if (err != 0) {
+ errno = err;
+ ret = -1;
+ }
+
+ return ret;
}
static int
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index b0ba504457..a53e0716a7 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -212,6 +212,8 @@ struct _header_scan_state {
int fd; /* input for a fd input */
CamelStream *stream; /* or for a stream */
+ int ioerrno; /* io error state */
+
/* for scanning input buffers */
char *realbuf; /* the real buffer, SCAN_HEAD*2 + SCAN_BUF bytes */
char *inbuf; /* points to a subset of the allocated memory, the underflow */
@@ -944,6 +946,14 @@ int camel_mime_parser_fd(CamelMimeParser *m)
return s->fd;
}
+/* Return errno of the parser, incase any error occured during processing */
+int camel_mime_parser_errno(CamelMimeParser *m)
+{
+ struct _header_scan_state *s = _PRIVATE(m);
+
+ return s->ioerrno;
+}
+
/* ********************************************************************** */
/* Implementation */
/* ********************************************************************** */
@@ -978,6 +988,8 @@ folder_read(struct _header_scan_state *s)
s->inptr = s->inbuf;
s->inend = s->inbuf+len+inoffset;
r(printf("content = %d '%.*s'\n",s->inend - s->inptr, s->inend - s->inptr, s->inptr));
+ } else {
+ s->ioerrno = errno?errno:EIO;
}
g_assert(s->inptr<=s->inend);
@@ -1035,8 +1047,12 @@ folder_seek(struct _header_scan_state *s, off_t offset, int whence)
if (len>=0) {
s->inend = s->inbuf+len;
s->inend[0] = '\n';
- } else
+ } else {
newoffset = -1;
+ s->ioerrno = errno?errno:EIO;
+ }
+ } else {
+ s->ioerrno = errno?errno:EIO;
}
#ifdef PURIFY
inend_id = purify_watch(&s->inend);
@@ -1474,6 +1490,7 @@ folder_scan_init(void)
s->fd = -1;
s->stream = NULL;
+ s->ioerrno = 0;
s->outbuf = g_malloc(1024);
s->outptr = s->outbuf;
@@ -1523,8 +1540,10 @@ folder_scan_init_with_fd(struct _header_scan_state *s, int fd)
camel_object_unref((CamelObject *)s->stream);
s->stream = NULL;
}
+ s->ioerrno = 0;
return 0;
} else {
+ s->ioerrno = errno?errno:EIO;
return -1;
}
}
@@ -1547,8 +1566,10 @@ folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream)
close(s->fd);
s->fd = -1;
}
+ s->ioerrno = 0;
return 0;
} else {
+ s->ioerrno = errno?errno:EIO;
return -1;
}
}
diff --git a/camel/camel-mime-parser.h b/camel/camel-mime-parser.h
index e0e3d036c0..c1ef1b58b4 100644
--- a/camel/camel-mime-parser.h
+++ b/camel/camel-mime-parser.h
@@ -76,6 +76,9 @@ struct _CamelMimeParserClass {
guint camel_mime_parser_get_type (void);
CamelMimeParser *camel_mime_parser_new (void);
+/* quick-fix for parser not erroring, we can find out if it had an error afterwards */
+int camel_mime_parser_errno (CamelMimeParser *);
+
/* using an fd will be a little faster, but not much (over a simple stream) */
int camel_mime_parser_init_with_fd(CamelMimeParser *, int fd);
int camel_mime_parser_init_with_stream(CamelMimeParser *m, CamelStream *stream);
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 55eb4a7492..303fba6c7d 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -30,6 +30,8 @@
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
+
#include <gal/util/e-iconv.h>
#include "hash-table-utils.h"
@@ -663,6 +665,7 @@ construct_from_parser(CamelMimePart *dw, CamelMimeParser *mp)
const char *content;
char *buf;
int len;
+ int err;
d(printf("mime_part::construct_from_parser()\n"));
@@ -696,6 +699,13 @@ construct_from_parser(CamelMimePart *dw, CamelMimeParser *mp)
#ifndef NO_WARNINGS
#warning "Need to work out how to detect a (fatally) bad parse in the parser"
#endif
+
+ err = camel_mime_parser_errno(mp);
+ if (err != 0) {
+ errno = err;
+ return -1;
+ }
+
return 0;
}
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index fc9ab999cb..5336cb39c3 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -226,7 +226,8 @@ static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar *
message = camel_mime_message_new();
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, _("Cannot get message: %s\n %s"),
+ camel_exception_setv(ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ _("Cannot get message: %s\n %s"),
name, _("Invalid message contents"));
g_free(name);
camel_object_unref((CamelObject *)message_stream);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index eb3faf166b..c2b98c9aa3 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -387,8 +387,7 @@ retry:
message = camel_mime_message_new();
if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
- g_warning("Construction failed");
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ camel_exception_setv(ex, errno==EINTR?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_FOLDER_INVALID_UID,
_("Cannot get message: %s from folder %s\n %s"), uid, lf->folder_path,
_("Message construction failed: Corrupt mailbox?"));
camel_object_unref((CamelObject *)parser);
diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c
index 298f04428e..d63e760df4 100644
--- a/camel/providers/local/camel-spool-folder.c
+++ b/camel/providers/local/camel-spool-folder.c
@@ -635,8 +635,7 @@ retry:
message = camel_mime_message_new();
if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
- g_warning("Construction failed");
- camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+ camel_exception_setv(ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_FOLDER_INVALID_UID,
_("Cannot get message: %s from folder %s\n %s"), uid, lf->folder_path,
_("Message construction failed: Corrupt mailbox?"));
camel_object_unref((CamelObject *)parser);