1189141Sdas/* 2189141Sdas * Copyright (c) 1999-2003, 2006 Proofpoint, Inc. and its suppliers. 3189141Sdas * All rights reserved. 4189141Sdas * 5189141Sdas * By using this file, you agree to the terms and conditions set 6189141Sdas * forth in the LICENSE file which can be found at the top level of 7189141Sdas * the sendmail distribution. 8189141Sdas * 9189141Sdas */ 10189141Sdas 11189141Sdas#include <sm/gen.h> 12189141SdasSM_RCSID("@(#)$Id: handler.c,v 8.40 2013-11-22 20:51:36 ca Exp $") 13189141Sdas 14189141Sdas#include "libmilter.h" 15189141Sdas 16189141Sdas#if !_FFR_WORKERS_POOL 17189141Sdas/* 18189141Sdas** MI_HANDLE_SESSION -- Handle a connected session in its own context 19189141Sdas** 20189141Sdas** Parameters: 21189141Sdas** ctx -- context structure 22189141Sdas** 23189141Sdas** Returns: 24189141Sdas** MI_SUCCESS/MI_FAILURE 25189141Sdas*/ 26189141Sdas 27189141Sdasint 28189141Sdasmi_handle_session(ctx) 29189141Sdas SMFICTX_PTR ctx; 30189141Sdas{ 31189141Sdas int ret; 32189141Sdas 33189141Sdas if (ctx == NULL) 34189141Sdas return MI_FAILURE; 35189141Sdas ctx->ctx_id = (sthread_t) sthread_get_id(); 36189141Sdas 37189141Sdas /* 38189141Sdas ** Detach so resources are freed when the thread returns. 39189141Sdas ** If we ever "wait" for threads, this call must be removed. 40189141Sdas */ 41189141Sdas 42189141Sdas if (pthread_detach(ctx->ctx_id) != 0) 43189141Sdas ret = MI_FAILURE; 44189141Sdas else 45290537Sngie ret = mi_engine(ctx); 46189141Sdas mi_clr_ctx(ctx); 47189141Sdas ctx = NULL; 48189141Sdas return ret; 49189141Sdas} 50189141Sdas#endif /* !_FFR_WORKERS_POOL */ 51189141Sdas