MCPcopy Create free account
hub / github.com/apache/brpc / load_bugs

Method load_bugs

tools/trackme_server/trackme_server.cpp:171–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void BugsLoader::load_bugs() {
172 butil::ScopedFILE fp(fopen(_bugs_file.c_str(), "r"));
173 if (!fp) {
174 PLOG(WARNING) << "Fail to open `" << _bugs_file << '\'';
175 return;
176 }
177
178 char* line = NULL;
179 size_t line_len = 0;
180 ssize_t nr = 0;
181 int nline = 0;
182 std::unique_ptr<BugList> m(new BugList);
183 while ((nr = getline(&line, &line_len, fp.get())) != -1) {
184 ++nline;
185 if (line[nr - 1] == '\n') { // remove ending newline
186 --nr;
187 }
188 // line format:
189 // min_rev <sp> max_rev <sp> severity <sp> description
190 butil::StringMultiSplitter sp(line, line + nr, " \t");
191 if (!sp) {
192 continue;
193 }
194 long long min_rev;
195 if (sp.to_longlong(&min_rev)) {
196 LOG(WARNING) << "[line" << nline << "] Fail to parse column1 as min_rev";
197 continue;
198 }
199 ++sp;
200 long long max_rev;
201 if (!sp || sp.to_longlong(&max_rev)) {
202 LOG(WARNING) << "[line" << nline << "] Fail to parse column2 as max_rev";
203 continue;
204 }
205 if (max_rev < min_rev) {
206 LOG(WARNING) << "[line" << nline << "] max_rev=" << max_rev
207 << " is less than min_rev=" << min_rev;
208 continue;
209 }
210 ++sp;
211 if (!sp) {
212 LOG(WARNING) << "[line" << nline << "] Fail to parse column3 as severity";
213 continue;
214 }
215 brpc::TrackMeSeverity severity = brpc::TrackMeOK;
216 butil::StringPiece severity_str(sp.field(), sp.length());
217 if (severity_str == "f" || severity_str == "F") {
218 severity = brpc::TrackMeFatal;
219 } else if (severity_str == "w" || severity_str == "W") {\
220 severity = brpc::TrackMeWarning;
221 } else {
222 LOG(WARNING) << "[line" << nline << "] Invalid severity=" << severity_str;
223 continue;
224 }
225 ++sp;
226 if (!sp) {
227 LOG(WARNING) << "[line" << nline << "] Fail to parse column4 as string";
228 continue;

Callers

nothing calls this directly

Calls 11

to_longlongMethod · 0.80
fieldMethod · 0.80
c_strMethod · 0.45
getMethod · 0.45
lengthMethod · 0.45
assignMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
resetMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected