freebsd-dev/contrib/sendmail/libmilter/handler.c

68 lines
1.3 KiB
C
Raw Normal View History

/*
2007-04-09 01:38:51 +00:00
* Copyright (c) 1999-2003, 2006 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.
*
*/
2002-02-17 21:56:45 +00:00
#include <sm/gen.h>
2007-04-09 01:38:51 +00:00
SM_RCSID("@(#)$Id: handler.c,v 8.38 2006/11/02 02:38:22 ca Exp $")
#include "libmilter.h"
2007-04-09 01:38:51 +00:00
#if !_FFR_WORKERS_POOL
/*
** HANDLE_SESSION -- Handle a connected session in its 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 = (sthread_t) sthread_get_id();
/*
2003-02-08 20:31:29 +00:00
** Detach so resources are free when the thread returns.
** If we ever "wait" for threads, this call must be removed.
*/
2002-06-11 21:12:04 +00:00
if (pthread_detach(ctx->ctx_id) != 0)
2002-06-11 21:12:04 +00:00
ret = MI_FAILURE;
else
ret = mi_engine(ctx);
if (ValidSocket(ctx->ctx_sd))
2001-01-21 22:17:06 +00:00
{
2002-02-17 21:56:45 +00:00
(void) closesocket(ctx->ctx_sd);
2001-01-21 22:17:06 +00:00
ctx->ctx_sd = INVALID_SOCKET;
}
if (ctx->ctx_reply != NULL)
2001-01-21 22:17:06 +00:00
{
free(ctx->ctx_reply);
2001-01-21 22:17:06 +00:00
ctx->ctx_reply = NULL;
}
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;
}
2007-04-09 01:38:51 +00:00
#endif /* !_FFR_WORKERS_POOL */