* Attach to a set of directories that was created with SharedFileSetInit. */
| 124 | * Attach to a set of directories that was created with SharedFileSetInit. |
| 125 | */ |
| 126 | void |
| 127 | SharedFileSetAttach(SharedFileSet *fileset, dsm_segment *seg) |
| 128 | { |
| 129 | bool success; |
| 130 | |
| 131 | SpinLockAcquire(&fileset->mutex); |
| 132 | if (fileset->refcnt == 0) |
| 133 | success = false; |
| 134 | else |
| 135 | { |
| 136 | ++fileset->refcnt; |
| 137 | success = true; |
| 138 | } |
| 139 | SpinLockRelease(&fileset->mutex); |
| 140 | |
| 141 | if (!success) |
| 142 | ereport(ERROR, |
| 143 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
| 144 | errmsg("could not attach to a SharedFileSet that is already destroyed"))); |
| 145 | |
| 146 | /* Register our cleanup callback. */ |
| 147 | on_dsm_detach(seg, SharedFileSetOnDetach, PointerGetDatum(fileset)); |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * Create a new file in the given set. |
no test coverage detected