1 /*
2  * Copyright 1993 Network Computing Devices, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name Network Computing Devices, Inc. not be
9  * used in advertising or publicity pertaining to distribution of this
10  * software without specific, written prior permission.
11  *
12  * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
13  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14  * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
16  * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17  * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18  * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19  * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * $NCDId: @(#)CloseSvr.c,v 1.4 1993/05/14 18:20:47 greg Exp $
23  */
24 
25 /* Portions derived from */
26 /* $XConsortium: XClDisplay.c,v 11.24 91/12/19 18:06:28 rws Exp $ */
27 /*
28 
29 Copyright 1985, 1990 by the Massachusetts Institute of Technology
30 
31 Permission to use, copy, modify, distribute, and sell this software and its
32 documentation for any purpose is hereby granted without fee, provided that
33 the above copyright notice appear in all copies and that both that
34 copyright notice and this permission notice appear in supporting
35 documentation, and that the name of M.I.T. not be used in advertising or
36 publicity pertaining to distribution of the software without specific,
37 written prior permission.  M.I.T. makes no representations about the
38 suitability of this software for any purpose.  It is provided "as is"
39 without express or implied warranty.
40 
41 */
42 
43 #include "Alibint.h"
44 
45 /*
46  * AuCloseServer - AuSync the connection to the audio server, close the
47  * connection,
48  * and free all associated storage.  Extension close procs should only free
49  * memory and must be careful about the types of requests they generate.
50  */
51 
52 void
AuCloseServer(AuServer * aud)53 AuCloseServer (AuServer *aud)
54 {
55 	_AuExtension *ext;
56 
57 	_AuFreeBucketCache(aud);
58 
59 	if (!(aud->flags & AuServerFlagsClosing))
60 	{
61 	    aud->flags |= AuServerFlagsClosing;
62 	    ext = aud->ext_procs;
63 	    while (ext) {	/* call out to any extensions interested */
64 		    if (ext->close_server != NULL)
65 			    (*ext->close_server)(aud, &ext->codes);
66 		    ext = ext->next;
67 	    }
68 	    AuSync(aud, 1);  /* throw away pending input events */
69 	}
70 	_AuDisconnectServer(aud->fd);
71 	_AuFreeServerStructure (aud);
72 	return;
73 }
74