diff options
author | Marcus Brinkmann <[email protected]> | 2009-11-05 02:15:04 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2009-11-05 02:15:04 +0000 |
commit | a0cb80c8f2798e22d49e6ed92ad42c45156ecc9e (patch) | |
tree | f821ad239666fbec5106b69d251fe200a54188bd /src/assuan-handler.c | |
parent | Extended HELP command. (diff) | |
download | libassuan-a0cb80c8f2798e22d49e6ed92ad42c45156ecc9e.tar.gz libassuan-a0cb80c8f2798e22d49e6ed92ad42c45156ecc9e.zip |
doc/
2009-11-05 Marcus Brinkmann <[email protected]>
* assuan.texi (External I/O Loop Server): Document change to
assuan_process_next.
src/
2009-11-05 Marcus Brinkmann <[email protected]>
* assuan-defs.h (assuan_context_t): Add member PROCESS_DONE.
* assuan.h (assuan_process_next): Add argument DONE to prototype.
* assuan-handler.c (assuan_process_next): Likewise, handle it.
(std_handler_bye): Set PROCESS_DONE.
(assuan_process_done): Handle PROCESS_DONE in the no error case.
(assuan_process): Use PROCESS_DONE.
Diffstat (limited to 'src/assuan-handler.c')
-rw-r--r-- | src/assuan-handler.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/assuan-handler.c b/src/assuan-handler.c index dd5bfda..21cf8cf 100644 --- a/src/assuan-handler.c +++ b/src/assuan-handler.c @@ -125,7 +125,8 @@ std_handler_bye (assuan_context_t ctx, char *line) assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); /* pretty simple :-) */ - return PROCESS_DONE (ctx, _assuan_error (ctx, GPG_ERR_EOF)); + ctx->process_done = 1; + return PROCESS_DONE (ctx, 0); } static gpg_error_t @@ -592,18 +593,19 @@ assuan_process_done (assuan_context_t ctx, gpg_error_t rc) /* Error handling. */ if (!rc) { - rc = assuan_write_line (ctx, ctx->okay_line ? ctx->okay_line : "OK"); - } - else if (gpg_err_code (rc) == GPG_ERR_EOF) - { /* No error checking because the peer may have already disconnect. */ - assuan_write_line (ctx, "OK closing connection"); - ctx->finish_handler (ctx); + if (ctx->process_done) + { + /* No error checking because the peer may have already + disconnect. */ + assuan_write_line (ctx, "OK closing connection"); + ctx->finish_handler (ctx); + } + else + rc = assuan_write_line (ctx, ctx->okay_line ? ctx->okay_line : "OK"); } else { - char errline[300]; - - const char *text = ctx->err_no == rc ? ctx->err_str : NULL; + char errline const char *text = ctx->err_no == rc ? ctx->err_str : NULL; char ebuf[50]; gpg_strerror_r (rc, ebuf, sizeof (ebuf)); @@ -686,18 +688,24 @@ process_next (assuan_context_t ctx) ready for reading. If the equivalent to EWOULDBLOCK is returned (this should be done by the command handler), assuan_process_next should be invoked the next time the connected FD is readable. - Eventually, the caller will finish by invoking - assuan_process_done. */ + Eventually, the caller will finish by invoking assuan_process_done. + DONE is set to 1 if the connection has ended. */ gpg_error_t -assuan_process_next (assuan_context_t ctx) +assuan_process_next (assuan_context_t ctx, int *done) { gpg_error_t rc; + if (done) + *done = 0; + ctx->process_done = 0; do { rc = process_next (ctx); } - while (!rc && assuan_pending_line (ctx)); + while (!rc && !ctx->process_done && assuan_pending_line (ctx)); + + if (done) + *done = !!ctx->process_done; return rc; } @@ -747,12 +755,10 @@ assuan_process (assuan_context_t ctx) { gpg_error_t rc; + ctx->process_done = 0; do { rc = process_request (ctx); - } while (!rc); - - if (gpg_err_code (rc) == GPG_ERR_EOF) - rc = 0; + } while (!rc && !ctx->process_done); return rc; } |