MCPcopy Index your code
hub / github.com/syncthing/syncthing / checkForProblems

Method checkForProblems

lib/rc/rc.go:406–451  ·  view source on GitHub ↗
(logfd *os.File)

Source from the content-addressed store, hash-verified

404}
405
406func (p *Process) checkForProblems(logfd *os.File) error {
407 fd, err := os.Open(logfd.Name())
408 if err != nil {
409 return err
410 }
411 defer fd.Close()
412
413 raceConditionStart := []byte("WARNING: DATA RACE")
414 raceConditionSep := []byte("==================")
415 panicConditionStart := []byte("panic:")
416 panicConditionSep := []byte("[") // fallback if we don't already know our ID
417 if p.id.String() != "" {
418 panicConditionSep = []byte(p.id.String()[:5])
419 }
420 sc := bufio.NewScanner(fd)
421 race := false
422 _panic := false
423
424 for sc.Scan() {
425 line := sc.Bytes()
426 if race || _panic {
427 if bytes.Contains(line, panicConditionSep) {
428 _panic = false
429 continue
430 }
431 fmt.Printf("%s\n", line)
432 if bytes.Contains(line, raceConditionSep) {
433 race = false
434 }
435 } else if bytes.Contains(line, raceConditionStart) {
436 fmt.Printf("%s\n", raceConditionSep)
437 fmt.Printf("%s\n", raceConditionStart)
438 race = true
439 if err == nil {
440 err = errors.New("Race condition detected")
441 }
442 } else if bytes.Contains(line, panicConditionStart) {
443 _panic = true
444 if err == nil {
445 err = errors.New("Panic detected")
446 }
447 }
448 }
449
450 return err
451}
452
453func (p *Process) eventLoop() {
454 since := 0

Callers 1

waitMethod · 0.95

Calls 8

BytesMethod · 0.80
ContainsMethod · 0.80
OpenMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
ScanMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected