summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/sendmail/libmilter/handler.c
blob: 0a805b757522d12fb0d3446f0084e47f9f153641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 *  Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers.
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at the top level of
 * the sendmail distribution.
 *
 */

#ifndef lint
static char id[] = "@(#)$Sendmail: handler.c,v 8.19 2000/02/11 00:12:29 ca Exp $";
#endif /* ! lint */

#if _FFR_MILTER
#include "libmilter.h"

/*
**  HANDLE_SESSION -- Handle a connected session in it's own context
**
**	Parameters:
**		ctx -- context structure
**
**	Returns:
**		MI_SUCCESS/MI_FAILURE
*/

int
mi_handle_session(ctx)
	SMFICTX_PTR ctx;
{
	int ret;

	if (ctx == NULL)
		return MI_FAILURE;
	ctx->ctx_id = pthread_self();

	/*
	**  detach so resources are free when the thread returns
	**  if we ever "wait" for threads, this call must be removed
	*/
	if (pthread_detach(ctx->ctx_id) != 0)
		return MI_FAILURE;
	ret = mi_engine(ctx);
	if (ctx->ctx_fd >= 0)
		(void) close(ctx->ctx_fd);
	if (ctx->ctx_reply != NULL)
		free(ctx->ctx_reply);
	if (ctx->ctx_privdata != NULL)
	{
		smi_log(SMI_LOG_WARN,
			"%s: private data not NULL",
			ctx->ctx_smfi->xxfi_name);
	}
	mi_clr_macros(ctx, 0);
	free(ctx);
	ctx = NULL;
	return ret;
}
#endif /* _FFR_MILTER */