Called when the remap.config file changes. Since it called infrequently, we do the load of new file as blocking I/O and lock acquire is also blocking. */
| 135 | |
| 136 | */ |
| 137 | bool |
| 138 | reloadUrlRewrite() |
| 139 | { |
| 140 | UrlRewrite *newTable, *oldTable; |
| 141 | |
| 142 | Note("%s loading ...", ts::filename::REMAP); |
| 143 | Dbg(dbg_ctl_url_rewrite, "%s updated, reloading...", ts::filename::REMAP); |
| 144 | newTable = new UrlRewrite(); |
| 145 | if (newTable->load()) { |
| 146 | static const char *msg_format = "%s finished loading"; |
| 147 | |
| 148 | // Hold at least one lease, until we reload the configuration |
| 149 | newTable->acquire(); |
| 150 | |
| 151 | // Swap configurations |
| 152 | oldTable = ink_atomic_swap(&rewrite_table, newTable); |
| 153 | |
| 154 | ink_assert(oldTable != nullptr); |
| 155 | |
| 156 | // Release the old one |
| 157 | oldTable->release(); |
| 158 | |
| 159 | Dbg(dbg_ctl_url_rewrite, msg_format, ts::filename::REMAP); |
| 160 | Note(msg_format, ts::filename::REMAP); |
| 161 | return true; |
| 162 | } else { |
| 163 | static const char *msg_format = "%s failed to load"; |
| 164 | |
| 165 | delete newTable; |
| 166 | Dbg(dbg_ctl_url_rewrite, msg_format, ts::filename::REMAP); |
| 167 | Error(msg_format, ts::filename::REMAP); |
| 168 | return false; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | int |
| 173 | url_rewrite_CB(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData data, void *cookie) |
no test coverage detected