From 0c12494ae485f7c025731a98183417d1afe2895c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 5 Oct 2007 16:01:12 +0000 Subject: 2007-10-05 Marcus Brinkmann * assuan-defs.h (_assuan_sock_wsa2errno) [HAVE_W32_SYSTEM]: Add prototype. * assuan-uds.c (wsa2errno) [HAVE_W32_SYSTEM]: Move and rename to ... * assuan-socket.c (_assuan_sock_wsa2errno) [HAVE_W32_SYSTEM]: ... this. (_assuan_close, _assuan_sock_new, _assuan_sock_connect, _assuan_sock_bind): Always set errno on error. --- src/assuan-buffer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/assuan-buffer.c') diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c index 8a9faf1..2016864 100644 --- a/src/assuan-buffer.c +++ b/src/assuan-buffer.c @@ -51,9 +51,10 @@ writen (assuan_context_t ctx, const char *buffer, size_t length) return 0; /* okay */ } -/* Read an entire line. Returns 0 on success or -1 and ERRNo on +/* Read an entire line. Returns 0 on success or -1 and ERRNO on failure. EOF is indictated by setting the integer at address - R_EOF. */ + R_EOF. Note: BUF, R_NREAD and R_EOF contain a valid result even if + an error is returned. */ static int readline (assuan_context_t ctx, char *buf, size_t buflen, int *r_nread, int *r_eof) @@ -132,12 +133,23 @@ _assuan_read_line (assuan_context_t ctx) &nread, &ctx->inbound.eof); if (rc) { + int saved_errno = errno; + if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), (int)ctx->inbound.fd, strerror (errno)); - + + if (saved_errno == EAGAIN) + { + /* We have to save a partial line. */ + memcpy (ctx->inbound.attic.line, line, atticlen + nread); + ctx->inbound.attic.pending = 0; + ctx->inbound.attic.linelen = atticlen + nread; + } + + errno = saved_errno; return _assuan_error (ASSUAN_Read_Error); } if (!nread) -- cgit v1.2.3