MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / remove_resource

Function remove_resource

src/utilities/drop.cpp:186–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185#ifndef HAVE_MMAP
186static void remove_resource(const TEXT* filename, SLONG shm_length, const TEXT* label)
187{
188/**************************************
189 *
190 * r e m o v e _ r e s o u r c e ( n o n - m m a p )
191 *
192 **************************************
193 *
194 * Functional description
195 *
196 **************************************/
197 ISC_STATUS_ARRAY status_vector;
198 SH_MEM_T shmem_data;
199 TEXT expanded_filename[MAXPATHLEN];
200
201 gds__prefix_lock(expanded_filename, filename);
202
203 if (!ISC_map_file
204#ifdef HP11
205 (status_vector, expanded_filename,
206 (void (*) (void*, sh_mem*, bool)) dummy_init, 0, shm_length, &shmem_data))
207#else
208 (status_vector, expanded_filename, dummy_init, 0, shm_length, &shmem_data))
209#endif
210 {
211 printf("\n***Unable to access %s resources:\n", label);
212 gds__print_status(status_vector);
213 return;
214 }
215
216 const SLONG key = get_key(expanded_filename);
217 if (key == -1)
218 {
219 printf("\n***Unable to get the key value of the %s file.\n", label);
220 return;
221 }
222
223 SLONG shmid = shm_exclusive(key, shmem_data.sh_mem_length_mapped);
224 if (shmid == -1)
225 {
226 printf("\n***File for %s is currently in use.\n", label);
227 return;
228 }
229
230 if (shmctl(shmid, IPC_RMID, 0) == -1)
231 printf("\n***Error trying to drop %s file. ERRNO = %d.\n", label, errno);
232 else
233 printf("Successfully removed %s file.\n", label);
234}
235#endif
236
237

Callers 1

CLIB_ROUTINE mainFunction · 0.85

Calls 2

shm_exclusiveFunction · 0.85
get_keyFunction · 0.70

Tested by

no test coverage detected