| 146 | } |
| 147 | |
| 148 | void BugsLoader::run() { |
| 149 | // Check status of _bugs_files periodically. |
| 150 | butil::FileWatcher fw; |
| 151 | if (fw.init(_bugs_file.c_str()) < 0) { |
| 152 | LOG(ERROR) << "Fail to init FileWatcher on `" << _bugs_file << "'"; |
| 153 | return; |
| 154 | } |
| 155 | while (!_stop) { |
| 156 | load_bugs(); |
| 157 | while (!_stop) { |
| 158 | butil::FileWatcher::Change change = fw.check_and_consume(); |
| 159 | if (change > 0) { |
| 160 | break; |
| 161 | } |
| 162 | if (change < 0) { |
| 163 | LOG(ERROR) << "`" << _bugs_file << "' was deleted"; |
| 164 | } |
| 165 | sleep(1); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | } |
| 170 | |
| 171 | void BugsLoader::load_bugs() { |
| 172 | butil::ScopedFILE fp(fopen(_bugs_file.c_str(), "r")); |
no test coverage detected