summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2001-12-14 19:35:56 +0000
committerWerner Koch <wk@gnupg.org>2001-12-14 19:35:56 +0000
commitcfe7ddef47bd2707798e6ca417fbcbb6e7e2f927 (patch)
tree2c7c824f5d16ca23c4d52b6b2410011e7bfbd086
parentbf3161a1d930ca323293def2cb990ab38584524b (diff)
downloadlibassuan-cfe7ddef47bd2707798e6ca417fbcbb6e7e2f927.tar.gz
* assuan-listen.c (assuan_close_input_fd): New.V0-0-0NEWPG-0-0-0
(assuan_close_output_fd): New. * assuan-handler.c (std_handler_reset): Always close them after a reset command. (std_handler_bye): Likewise.
-rw-r--r--src/ChangeLog8
-rw-r--r--src/assuan-handler.c4
-rw-r--r--src/assuan-listen.c26
-rw-r--r--src/assuan.h2
4 files changed, 40 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5ccba92..f85e220 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2001-12-14 Werner Koch <wk@gnupg.org>
+
+ * 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 <marcus@g10code.de>
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 8ec8b23..a82bd53 100644
--- a/src/assuan-handler.c
+++ b/src/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/src/assuan-listen.c b/src/assuan-listen.c
index 822ef32..57fe4b6 100644
--- a/src/assuan-listen.c
+++ b/src/assuan-listen.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#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/src/assuan.h b/src/assuan.h
index 485ad22..a4f887f 100644
--- a/src/assuan.h
+++ b/src/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 --*/