aboutsummaryrefslogtreecommitdiff
path: root/sys/ki/kifchan.x
blob: 199212b28383044e9ced9c900b449df5fd07e7a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <config.h>
include "ki.h"

# KI_FREECHAN -- Free a channel descriptor slot.  Decrement the reference
# count on the associated node descriptor slot; when the ref count reaches
# zero, free the node descriptor if the error bit is set.  If the error
# bit is not set the node descriptor is not freed because the kernel server
# remains connected, ready for reuse.

procedure ki_freechan (chan)

int	chan			# kichan channel descriptor

int	server, and()
include	"kichan.com"
include	"kinode.com"

begin
	server = k_node[chan]

	# Server=0 if local node.
	if (server > 0) {
	    n_nrefs[server] = n_nrefs[server] - 1
	    if (and (n_status[server], F_IOERR) != 0)
		if (n_nrefs[server] == 0)
		    n_status[server] = F_IOERR + F_REUSE
	}
	    
	k_oschan[chan] = NULL
end