* Callback function that will be invoked when this backend detaches from a * DSM segment holding a SharedFileSet that it has created or attached to. If * we are the last to detach, then try to remove the directories and * everything in them. We can't raise an error on failures, because this runs * in error cleanup paths. */
| 238 | * in error cleanup paths. |
| 239 | */ |
| 240 | static void |
| 241 | SharedFileSetOnDetach(dsm_segment *segment, Datum datum) |
| 242 | { |
| 243 | bool unlink_all = false; |
| 244 | SharedFileSet *fileset = (SharedFileSet *) DatumGetPointer(datum); |
| 245 | |
| 246 | SpinLockAcquire(&fileset->mutex); |
| 247 | Assert(fileset->refcnt > 0); |
| 248 | if (--fileset->refcnt == 0) |
| 249 | unlink_all = true; |
| 250 | SpinLockRelease(&fileset->mutex); |
| 251 | |
| 252 | /* |
| 253 | * If we are the last to detach, we delete the directory in all |
| 254 | * tablespaces. Note that we are still actually attached for the rest of |
| 255 | * this function so we can safely access its data. |
| 256 | */ |
| 257 | if (unlink_all) |
| 258 | SharedFileSetDeleteAll(fileset); |
| 259 | } |
| 260 | |
| 261 | /* |
| 262 | * Callback function that will be invoked on the process exit. This will |
nothing calls this directly
no test coverage detected