File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
17
17
"regexp"
18
18
"strconv"
19
19
"strings"
20
+ "sync"
20
21
)
21
22
22
23
var (
@@ -68,6 +69,7 @@ type FileParser struct {
68
69
started bool
69
70
event * Event
70
71
err error
72
+ * sync.Mutex
71
73
}
72
74
73
75
var Debug = false
@@ -86,13 +88,16 @@ func NewFileParser(file *os.File) *FileParser {
86
88
queryLines : 0 ,
87
89
lineOffset : 0 ,
88
90
event : NewEvent (),
91
+ Mutex : & sync.Mutex {},
89
92
}
90
93
return p
91
94
}
92
95
93
96
// Stop stops the parser before parsing the next event or while blocked on
94
97
// sending the current event to the event channel.
95
98
func (p * FileParser ) Stop () {
99
+ p .Lock ()
100
+ defer p .Unlock ()
96
101
if Debug {
97
102
log .Println ("stopping" )
98
103
}
@@ -107,6 +112,8 @@ func (p *FileParser) Stop() {
107
112
// Parsing stops on EOF, error, or call to Stop. The Events channel is closed
108
113
// when parsing stops.
109
114
func (p * FileParser ) Start (opt Options ) error {
115
+ p .Lock ()
116
+ defer p .Unlock ()
110
117
if p .started {
111
118
return ErrStarted
112
119
}
You can’t perform that action at this time.
0 commit comments