diff options
author | Marcus Brinkmann <[email protected]> | 2007-10-05 16:01:12 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2007-10-05 16:01:12 +0000 |
commit | 0c12494ae485f7c025731a98183417d1afe2895c (patch) | |
tree | 5660f0922d5a4c3b76d5f7e72a9ab2def374bf3e /src/assuan-buffer.c | |
parent | 2007-10-05 Marcus Brinkmann <[email protected]> (diff) | |
download | libassuan-0c12494ae485f7c025731a98183417d1afe2895c.tar.gz libassuan-0c12494ae485f7c025731a98183417d1afe2895c.zip |
2007-10-05 Marcus Brinkmann <[email protected]>
* 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.
Diffstat (limited to '')
-rw-r--r-- | src/assuan-buffer.c | 20 |
1 files changed, 16 insertions, 4 deletions
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) |