diff --git a/assuan/ChangeLog b/assuan/ChangeLog index 5ccba926d..f85e22042 100644 --- a/assuan/ChangeLog +++ b/assuan/ChangeLog @@ -1,3 +1,11 @@ +2001-12-14 Werner Koch + + * assuan-listen.c (assuan_close_input_fd): New. + (assuan_close_output_fd): New. + * assuan-handler.c (std_handler_reset): Always close them after a + reset command. + (std_handler_bye): Likewise. + 2001-12-14 Marcus Brinkmann * assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index 8ec8b2301..a82bd5379 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -54,6 +54,8 @@ std_handler_bye (ASSUAN_CONTEXT ctx, char *line) { if (ctx->bye_notify_fnc) ctx->bye_notify_fnc (ctx); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); return -1; /* pretty simple :-) */ } @@ -68,6 +70,8 @@ std_handler_reset (ASSUAN_CONTEXT ctx, char *line) { if (ctx->reset_notify_fnc) ctx->reset_notify_fnc (ctx); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); return 0; } diff --git a/assuan/assuan-listen.c b/assuan/assuan-listen.c index 822ef32cd..57fe4b669 100644 --- a/assuan/assuan-listen.c +++ b/assuan/assuan-listen.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "assuan-defs.h" @@ -106,3 +107,28 @@ assuan_get_output_fd (ASSUAN_CONTEXT ctx) } +/* Close the fd descriptor set by the command INPUT FD=n. We handle + this fd inside assuan so that we can do some initial checks */ +AssuanError +assuan_close_input_fd (ASSUAN_CONTEXT ctx) +{ + if (!ctx || ctx->input_fd == -1) + return ASSUAN_Invalid_Value; + close (ctx->input_fd); + ctx->input_fd = -1; + return 0; +} + +/* Close the fd descriptor set by the command OUTPUT FD=n. We handle + this fd inside assuan so that we can do some initial checks */ +AssuanError +assuan_close_output_fd (ASSUAN_CONTEXT ctx) +{ + if (!ctx || ctx->output_fd == -1) + return ASSUAN_Invalid_Value; + + close (ctx->output_fd); + ctx->output_fd = -1; + return 0; +} + diff --git a/assuan/assuan.h b/assuan/assuan.h index 485ad2225..a4f887f6f 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -136,6 +136,8 @@ AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line); AssuanError assuan_accept (ASSUAN_CONTEXT ctx); int assuan_get_input_fd (ASSUAN_CONTEXT ctx); int assuan_get_output_fd (ASSUAN_CONTEXT ctx); +AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx); +AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx); /*-- assuan-pipe-server.c --*/