Home | History | Annotate | Line # | Download | only in global
      1 /*	$NetBSD: timed_ipc.c,v 1.2 2017/02/14 01:16:45 christos Exp $	*/
      2 
      3 /*++
      4 /* NAME
      5 /*	timed_ipc 3
      6 /* SUMMARY
      7 /*	enforce IPC timeout on stream
      8 /* SYNOPSIS
      9 /*	#include <time_ipc.h>
     10 /*
     11 /*	void	timed_ipc_setup(stream)
     12 /*	VSTREAM	*stream;
     13 /* DESCRIPTION
     14 /*	timed_ipc() enforces on the specified stream the timeout as
     15 /*	specified via the \fIipc_timeout\fR configuration parameter:
     16 /*	a read or write operation fails if it does not succeed within
     17 /*	\fIipc_timeout\fR seconds. This deadline exists as a safety
     18 /*	measure for communication between mail subsystem programs,
     19 /*	and should never be exceeded.
     20 /* DIAGNOSTICS
     21 /*	Panic: sanity check failed. Fatal error: deadline exceeded.
     22 /* LICENSE
     23 /* .ad
     24 /* .fi
     25 /*	The Secure Mailer license must be distributed with this software.
     26 /* AUTHOR(S)
     27 /*	Wietse Venema
     28 /*	IBM T.J. Watson Research
     29 /*	P.O. Box 704
     30 /*	Yorktown Heights, NY 10598, USA
     31 /*--*/
     32 
     33 /* System library. */
     34 
     35 #include <sys_defs.h>
     36 
     37 /* Utility library. */
     38 
     39 #include <msg.h>
     40 #include <vstream.h>
     41 
     42 /* Global library. */
     43 
     44 #include "mail_params.h"
     45 #include "timed_ipc.h"
     46 
     47 /* timed_ipc_setup - enable ipc with timeout */
     48 
     49 void    timed_ipc_setup(VSTREAM *stream)
     50 {
     51     if (var_ipc_timeout <= 0)
     52 	msg_panic("timed_ipc_setup: bad ipc_timeout %d", var_ipc_timeout);
     53 
     54     vstream_control(stream,
     55 		    CA_VSTREAM_CTL_TIMEOUT(var_ipc_timeout),
     56 		    CA_VSTREAM_CTL_END);
     57 }
     58