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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
; SCCSID = @(#)abort.asm 1.4 85/10/02
TITLE DOS_ABORT - Internal SFT close all files for proc call for MSDOS
NAME DOS_ABORT
; Internal Abort call closes all handles and FCBs associated with a process.
; If process has NET resources a close all is sent out over the net.
;
; DOS_ABORT
;
; Modification history:
;
; Created: ARR 30 March 1983
;
;
; get the appropriate segment definitions
;
include dosseg.asm
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME SS:DOSGROUP,CS:DOSGROUP
.xlist
.xcref
INCLUDE DOSSYM.INC
INCLUDE DEVSYM.INC
.cref
.list
Installed = TRUE
I_Need PROC_ID,WORD ; current process ID
I_Need USER_ID,WORD ; current user ID
i_need CurrentPDB,WORD
i_need sft_addr,DWORD
i_need THISSFT,DWORD
i_need JSHARE,DWORD
I_need sftFCB,DWORD ; pointer to SFTs for FCB cache
Break <DOS_ABORT -- CLOSE all files for process>
; Inputs:
; [CurrentPDB] set to PID of process aborting
; Function:
; Close all files and free all SFTs for this PID
; Returns:
; None
; All destroyed except stack
Procedure DOS_ABORT,NEAR
ASSUME DS:NOTHING,ES:NOTHING
MOV ES,[CurrentPDB]
MOV CX,ES:[PDB_JFN_Length] ; Number of JFNs
reset_free_jfn:
MOV BX,CX
PUSH CX
DEC BX ; get jfn (start with last one)
invoke $close
POP CX
LOOP reset_free_jfn ; and do 'em all
;
; Note: We do need to explicitly close FCBs. Reasons are as follows: If we
; are running in the no-sharing no-network environment, we are simulating the
; 2.0 world and thus if the user doesn't close the file, that is his problem
; BUT... the cache remains in a state with garbage that may be reused by the
; next process. We scan the set and blast the ref counts of the FCBs we own.
;
; If sharing is loaded, then the following call to close process will
; correctly close all FCBs. We will then need to walk the list AFTER here.
;
; Finally, the following call to NET_Abort will cause an EOP to be sent to all
; known network resources. These resources are then responsible for cleaning
; up after this process.
;
; Sleazy, eh?
;
context DS
CallInstall Net_Abort, multNet, 29
if installed
call JShare + 4 * 4
else
call mftCloseP
endif
assume ds:nothing
;
; Scan the FCB cache for guys that belong to this process and zap their ref
; counts.
;
les di,sftFCB ; grab the pointer to the table
mov cx,es:[di].sfCount
jcxz FCBScanDone
LEA DI,[DI].sfTable ; point at table
mov ax,proc_id
FCBTest:
cmp es:[di].sf_PID,ax ; is this one of ours
jnz FCBNext ; no, skip it
mov es:[di].sf_ref_count,0 ; yes, blast ref count
FCBNext:
add di,size sf_Entry
loop FCBTest
FCBScanDone:
;
; Walk the SFT to eliminate all busy SFT's for this process.
;
XOR BX,BX
Scan:
push bx
invoke SFFromSFN
pop bx
retc
cmp es:[di].sf_ref_count,0
jz next
;
; we have a SFT that is not free. See if it is for the current process
;
mov ax,proc_id
cmp es:[di].sf_pid,ax
jnz next
mov ax,user_id
cmp es:[di].sf_uid,ax
jnz next
;
; This SFT is labelled as ours.
;
mov es:[di].sf_ref_count,0
next:
inc bx
jmp scan
EndProc DOS_Abort
CODE ENDS
END
|