{
register gchar *outptr, *inptr, *inend, c, *outend;
gint bytes_read;
+ GError *local_error = NULL;
outptr = buf;
inptr = (gchar *) sbf->priv->ptr;
bytes_read = camel_stream_read (
sbf->priv->stream, (gchar *) sbf->priv->buf,
- sbf->priv->size, cancellable, error);
+ sbf->priv->size, cancellable, &local_error);
if (bytes_read == -1) {
- if (buf == outptr)
+ if (buf == outptr) {
+ if (local_error)
+ g_propagate_error (error, local_error);
return -1;
- else
+ } else
bytes_read = 0;
}
sbf->priv->ptr = sbf->priv->buf;
sbf->priv->ptr = (guchar *) inptr;
*outptr = 0;
+ g_clear_error (&local_error);
+
return (gint)(outptr - buf);
}
{
guchar *p;
gint nread;
+ GError *local_error = NULL;
p = sbf->priv->linebuf;
while (1) {
nread = camel_stream_buffer_gets (
sbf, (gchar *) p, sbf->priv->linesize -
- (p - sbf->priv->linebuf), cancellable, error);
+ (p - sbf->priv->linebuf), cancellable, &local_error);
if (nread <=0) {
if (p > sbf->priv->linebuf)
break;
+ if (local_error)
+ g_propagate_error (error, local_error);
return NULL;
}
p--;
p[0] = 0;
+ g_clear_error (&local_error);
+
return g_strdup ((gchar *) sbf->priv->linebuf);
}
exception:
if (clean_quit && store->connected) {
- /* try to disconnect cleanly */
- response = camel_imap_command (store, NULL, cancellable, error, "LOGOUT");
+ /* try to disconnect cleanly; error is already set here */
+ response = camel_imap_command (store, NULL, cancellable, NULL, "LOGOUT");
if (response)
camel_imap_response_free_without_processing (store, response);
}
gchar linebuf[1024] = {0};
GByteArray *ba;
gssize nread;
+ GError *local_error = NULL;
g_return_val_if_fail (CAMEL_IS_IMAP_STORE (store), -1);
g_return_val_if_fail (dest, -1);
stream = CAMEL_STREAM_BUFFER (store->istream);
ba = g_byte_array_new ();
- while ((nread = camel_stream_buffer_gets (stream, linebuf, sizeof (linebuf), cancellable, error)) > 0) {
+ while ((nread = camel_stream_buffer_gets (stream, linebuf, sizeof (linebuf), cancellable, &local_error)) > 0) {
g_byte_array_append (ba, (const guint8 *) linebuf, nread);
if (linebuf[nread - 1] == '\n')
break;
}
- if (nread <= 0) {
- if (nread == 0)
+ if (nread <= 0 || local_error) {
+ if (!local_error)
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
_("Server unexpectedly disconnected"));
- else
+ else {
+ g_propagate_error (error, local_error);
g_prefix_error (
error, _("Server unexpectedly disconnected: "));
+ }
/* do not pass cancellable, the connection is gone or
* the cancellable cancelled, thus there will be no I/O */