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