diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 13 | ||||
-rw-r--r-- | src/assuan-defs.h | 1 | ||||
-rw-r--r-- | src/assuan-handler.c | 42 | ||||
-rw-r--r-- | src/assuan.h | 2 | ||||
-rw-r--r-- | src/debug.c | 1 |
5 files changed, 40 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0b766d9..c5d668e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +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. + +2009-11-04 Marcus Brinkmann <[email protected]> + + * debug.c (_assuan_debug): Free MSG. + 2009-11-04 Werner Koch <[email protected]> * Makefile.am (common_sources): Add debug.h. diff --git a/src/assuan-defs.h b/src/assuan-defs.h index 648b881..bd0cbc8 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -124,6 +124,7 @@ struct assuan_context_s int is_server; /* Set if this is context belongs to a server */ int in_inquire; int in_process_next; + int process_done; int in_command; /* The following members are used by assuan_inquire_ext. */ 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; } diff --git a/src/assuan.h b/src/assuan.h index defd0b6..c201294 100644 --- a/src/assuan.h +++ b/src/assuan.h @@ -327,7 +327,7 @@ gpg_error_t assuan_register_option_handler (assuan_context_t ctx, const char*)); gpg_error_t assuan_process (assuan_context_t ctx); -gpg_error_t assuan_process_next (assuan_context_t ctx); +gpg_error_t assuan_process_next (assuan_context_t ctx, int *done); gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc); int assuan_get_active_fds (assuan_context_t ctx, int what, assuan_fd_t *fdarray, int fdarraysize); diff --git a/src/debug.c b/src/debug.c index 1a0df7e..37d15cb 100644 --- a/src/debug.c +++ b/src/debug.c @@ -59,6 +59,7 @@ _assuan_debug (assuan_context_t ctx, unsigned int cat, const char *format, ...) if (res < 0) return; ctx->log_cb (ctx, ctx->log_cb_data, cat, msg); + free (msg); errno = saved_errno; } |