Line data Source code
1 : /* server.c - Interfaces for all assuan servers.
2 : Copyright (C) 2009 Free Software Foundation, Inc.
3 :
4 : This file is part of Assuan.
5 :
6 : Assuan is free software; you can redistribute it and/or modify it
7 : under the terms of the GNU Lesser General Public License as
8 : published by the Free Software Foundation; either version 2.1 of
9 : the License, or (at your option) any later version.
10 :
11 : Assuan is distributed in the hope that it will be useful, but
12 : WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public
17 : License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 : */
19 :
20 :
21 : #ifdef HAVE_CONFIG_H
22 : #include <config.h>
23 : #endif
24 :
25 : #include "assuan-defs.h"
26 : #include "debug.h"
27 :
28 :
29 :
30 : /* Disconnect and release the context CTX. */
31 : void
32 0 : _assuan_server_finish (assuan_context_t ctx)
33 : {
34 0 : if (ctx->inbound.fd != ASSUAN_INVALID_FD)
35 : {
36 0 : _assuan_close (ctx, ctx->inbound.fd);
37 0 : if (ctx->inbound.fd == ctx->outbound.fd)
38 0 : ctx->outbound.fd = ASSUAN_INVALID_FD;
39 0 : ctx->inbound.fd = ASSUAN_INVALID_FD;
40 : }
41 0 : if (ctx->outbound.fd != ASSUAN_INVALID_FD)
42 : {
43 0 : _assuan_close (ctx, ctx->outbound.fd);
44 0 : ctx->outbound.fd = ASSUAN_INVALID_FD;
45 : }
46 0 : if (ctx->pid != ASSUAN_INVALID_PID && ctx->pid)
47 : {
48 0 : _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0);
49 0 : ctx->pid = ASSUAN_INVALID_PID;
50 : }
51 :
52 0 : _assuan_uds_deinit (ctx);
53 :
54 0 : _assuan_inquire_release (ctx);
55 0 : }
56 :
57 :
58 : void
59 0 : _assuan_server_release (assuan_context_t ctx)
60 : {
61 0 : _assuan_server_finish (ctx);
62 :
63 0 : _assuan_free (ctx, ctx->hello_line);
64 0 : ctx->hello_line = NULL;
65 0 : _assuan_free (ctx, ctx->okay_line);
66 0 : ctx->okay_line = NULL;
67 0 : _assuan_free (ctx, ctx->cmdtbl);
68 0 : ctx->cmdtbl = NULL;
69 0 : }
|