diff options
author | Marcus Brinkmann <mb@g10code.com> | 2009-11-05 02:15:04 +0000 |
---|---|---|
committer | Marcus Brinkmann <mb@g10code.com> | 2009-11-05 02:15:04 +0000 |
commit | a0cb80c8f2798e22d49e6ed92ad42c45156ecc9e (patch) | |
tree | f821ad239666fbec5106b69d251fe200a54188bd | |
parent | 8b30641f35200d82897cd659d180e4423a803e85 (diff) | |
download | libassuan-a0cb80c8f2798e22d49e6ed92ad42c45156ecc9e.tar.gz |
doc/
2009-11-05 Marcus Brinkmann <marcus@g10code.de>
* assuan.texi (External I/O Loop Server): Document change to
assuan_process_next.
src/
2009-11-05 Marcus Brinkmann <marcus@g10code.de>
* 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.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/assuan.texi | 9 | ||||
-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 |
8 files changed, 50 insertions, 24 deletions
@@ -75,6 +75,7 @@ assuan_register_reset_notify CHANGED: Handler gets line and returns err now. assuan_register_cancel_notify CHANGED: Handler gets line and returns err now. assuan_register_input_notify CHANGED: Handler returns error now. assuan_register_output_notify CHANGED: Handler returns error now. +assuan_process_next CHANGED: New DONE argument instead EOF return. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/ChangeLog b/doc/ChangeLog index 6106e35..e625175 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann <marcus@g10code.de> + + * assuan.texi (External I/O Loop Server): Document change to + assuan_process_next. + 2009-10-16 Marcus Brinkmann <marcus@g10code.com> * assuan.texi: Remove documentation for thread support. diff --git a/doc/assuan.texi b/doc/assuan.texi index 5641aa0..eab2451 100644 --- a/doc/assuan.texi +++ b/doc/assuan.texi @@ -1524,8 +1524,8 @@ operation. When it returns, the inbound status FD may still be readable, but Assuan does not check this. The function @code{assuan_process_next} returns 0 if it can not make -progress reliably, and it returns an end of file error value if the -client closed the connection. See below for more information on this +progress reliably, and it returns true in @code{done} if the client +closed the connection. See below for more information on this function. @item @@ -1562,11 +1562,10 @@ the client with @code{assuan_process_done}. For long running operations, the server should send progress status messages to the client in regular intervals to notice when the client disconnects. -@deftypefun gpg_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}) +@deftypefun gpg_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}, @w{int *@var{done}}) This is the same as @code{assuan_process} but the caller has to provide the outer loop. He should loop as long as the return code is -zero and stop otherwise; @code{-1} or @code{GPG_ERR_EOF} indicate a -regular end. +zero and @var{done} is false. @end deftypefun @deftypefun gpg_error_t assuan_process_done (@w{assuan_context_t @var{ctx}}, @w{gpg_error_t @var{rc}}) 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 <marcus@g10code.de> + + * 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 <marcus@g10code.de> + + * debug.c (_assuan_debug): Free MSG. + 2009-11-04 Werner Koch <wk@g10code.com> * 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; } |