-
Notifications
You must be signed in to change notification settings - Fork 1
/
dat1_annul_lcp.c
150 lines (123 loc) · 6.91 KB
/
dat1_annul_lcp.c
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
138
139
140
141
142
143
144
145
146
147
148
149
150
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "ems.h" /* ems_ error message service routines */
#include "hds1.h" /* Global definitions for HDS */
#include "rec1.h" /* Internal rec_ definitions */
#include "dat1.h" /* Internal dat_ definitions */
#include "dat_err.h" /* DAT__ error code definitions */
void dat1_annul_lcp( struct LCP **lcp )
{
/*+ */
/* Name: */
/* dat1_annul_lcp */
/* Purpose: */
/* Annul a Locator Control Packet. */
/* Invocation: */
/* dat1_annul_lcp( lcp ) */
/* Description: */
/* This function annuls a Locator Control Packet (LCP), causing the */
/* associated locator to become invalid. Any mapped data associated with */
/* the LCP are flushed and the LCP is returned to the free locator */
/* queue. A null pointer is returned. If a primary LCP is supplied, the */
/* reference count for the associated container file is also */
/* decremented. If this count falls to zero, all other LCPs associated */
/* with the same file are also annulled, and the file is closed (and */
/* deleted if it was been marked for deletion). */
/* Parameters: */
/* struct LCP **lcp */
/* Pointer to a pointer to the LCP structure to be annulled; a null */
/* pointer value will be returned in *lcp. An error will result if */
/* *lcp is null on entry. */
/* Returned Value: */
/* void */
/* Notes: */
/* This routine attempts to execute even if the HDS global ststus is set */
/* on entry, although no further error report will be made if it */
/* subsequently fails under these circumstances. */
/* Copyright: */
/* Copyright (C) 1992 Science & Engineering Research Council */
/* Authors: */
/* RFWS: R.F. Warren-Smith (STARLINK) */
/* {@enter_new_authors_here@} */
/* History: */
/* 11-SEP-1992 (RFWS): */
/* Original version. */
/* {@enter_changes_here@} */
/* Bugs: */
/* {@note_any_bugs_here@} */
/*- */
/* Local Variables: */
int again; /* Process another queue element? */
int primary; /* Primary Locator Control Packet? */
int refcnt; /* Container file reference count */
struct HAN han; /* Handle to container file record */
struct LCP *next; /* Pointer to next queue element */
struct LCP *qpntr; /* Pointer to current queue element */
/*. */
/* Begin a new error reporting context. */
emsBegin( &hds_gl_status );
/* Check that the LCP pointer supplied is not null. Report an error if it */
/* is. */
if ( *lcp == NULL )
{
hds_gl_status = DAT__FATAL;
emsRep( "DAT1_ANNUL_LCP_1",
"Routine DAT1_ANNUL_LCP called with an invalid null LCP \
pointer (internal programming error).",
&hds_gl_status );
}
/* If the LCP is valid, then determine if it is a primary LCP. */
else
{
primary = (*lcp)->data.valid ? (*lcp)->primary : 0;
/* If it is not primary, then simply defuse it. */
if ( !primary )
{
dau_defuse_lcp( lcp );
}
/* Otherwise, obtain a handle to the associated container file record and */
/* decrement the file's reference count. */
else
{
han = (*lcp)->data.han;
rec_refcnt( &han, -1, &refcnt, &hds_gl_status );
if ( _ok( hds_gl_status ) )
{
/* If the reference count is still positive, then simply defuse the LCP. */
if ( refcnt > 0 )
{
dau_defuse_lcp( lcp );
}
/* Otherwise, obtain a pointer to the head of the Working Locator Queue and */
/* loop to identify all Locator Control Packets associated with this */
/* container file. */
else
{
again = 1;
for( qpntr = dat_ga_wlq; again; qpntr = next )
{
/* Obtain a pointer to the next element in the queue (while the current one */
/* still exists) and note whether we have reached the end of the queue. */
next = qpntr->flink;
again = ( next != dat_ga_wlq );
/* Defuse all LCPs associated with the container file in question (causing */
/* the associated locators to become invalid). */
if ( rec_same_file( &han, &qpntr->data.han ) )
{
dau_defuse_lcp( &qpntr );
}
}
/* After defusing all LCPs associated with the container file, close the */
/* file. */
rec_close_file( &han );
}
}
}
}
/* Return a null LCP pointer. */
*lcp = NULL;
/* End the error reporting context and exit the routine. */
emsEnd( &hds_gl_status );
return;
}