17c478bd9Sstevel@tonic-gate /* 2058561cbSjbeck * Copyright (c) 1999-2003, 2006 Sendmail, Inc. and its suppliers. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 67c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 77c478bd9Sstevel@tonic-gate * the sendmail distribution. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate */ 107c478bd9Sstevel@tonic-gate 117c478bd9Sstevel@tonic-gate #include <sm/gen.h> 12*e9af4bc0SJohn Beck SM_RCSID("@(#)$Id: handler.c,v 8.39 2008/11/25 01:14:16 ca Exp $") 137c478bd9Sstevel@tonic-gate 147c478bd9Sstevel@tonic-gate #include "libmilter.h" 157c478bd9Sstevel@tonic-gate 16058561cbSjbeck #if !_FFR_WORKERS_POOL 177c478bd9Sstevel@tonic-gate /* 187c478bd9Sstevel@tonic-gate ** HANDLE_SESSION -- Handle a connected session in its own context 197c478bd9Sstevel@tonic-gate ** 207c478bd9Sstevel@tonic-gate ** Parameters: 217c478bd9Sstevel@tonic-gate ** ctx -- context structure 227c478bd9Sstevel@tonic-gate ** 237c478bd9Sstevel@tonic-gate ** Returns: 247c478bd9Sstevel@tonic-gate ** MI_SUCCESS/MI_FAILURE 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate int 287c478bd9Sstevel@tonic-gate mi_handle_session(ctx) 297c478bd9Sstevel@tonic-gate SMFICTX_PTR ctx; 307c478bd9Sstevel@tonic-gate { 317c478bd9Sstevel@tonic-gate int ret; 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate if (ctx == NULL) 347c478bd9Sstevel@tonic-gate return MI_FAILURE; 357c478bd9Sstevel@tonic-gate ctx->ctx_id = (sthread_t) sthread_get_id(); 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate ** Detach so resources are free when the thread returns. 397c478bd9Sstevel@tonic-gate ** If we ever "wait" for threads, this call must be removed. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate if (pthread_detach(ctx->ctx_id) != 0) 437c478bd9Sstevel@tonic-gate ret = MI_FAILURE; 447c478bd9Sstevel@tonic-gate else 457c478bd9Sstevel@tonic-gate ret = mi_engine(ctx); 46*e9af4bc0SJohn Beck mi_clr_ctx(ctx); 477c478bd9Sstevel@tonic-gate ctx = NULL; 487c478bd9Sstevel@tonic-gate return ret; 497c478bd9Sstevel@tonic-gate } 50058561cbSjbeck #endif /* !_FFR_WORKERS_POOL */ 51