fix windows tailer closing issues

main
Ben Grewell 4 years ago
parent 0dc467f289
commit f9a882f5e4

@ -3,9 +3,10 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment=""> <list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client.go" beforeDir="false" afterPath="$PROJECT_DIR$/client.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/reporter.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/reporter.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/reporter_linux.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter_linux.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/reporter_linux.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter_linux.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tests/client/client.go" beforeDir="false" afterPath="$PROJECT_DIR$/tests/client/client.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/reporter_windows.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter_windows.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -492,7 +492,6 @@ func (c *Client) Start() (err error) {
if err != nil { if err != nil {
return err return err
} }
fmt.Println(cmd)
var exit chan int var exit chan int
c.outputStream, c.errorStream, exit, c.cancel, err = ExecuteAsyncWithCancel(cmd) c.outputStream, c.errorStream, exit, c.cancel, err = ExecuteAsyncWithCancel(cmd)
if err != nil { if err != nil {

@ -1,7 +1,6 @@
package iperf package iperf
import ( import (
"fmt"
"github.com/BGrewell/tail" "github.com/BGrewell/tail"
) )
@ -22,7 +21,6 @@ func (r *Reporter) Stop() {
r.tailer.Stop() r.tailer.Stop()
r.tailer.Cleanup() r.tailer.Cleanup()
close(r.ReportingChannel) close(r.ReportingChannel)
fmt.Println("reporter stopped")
} }
// runLogProcessor is OS specific because of differences in iperf on Windows and Linux // runLogProcessor is OS specific because of differences in iperf on Windows and Linux

@ -45,13 +45,12 @@ Connecting to host 10.254.100.100, port 5201
iperf Done. iperf Done.
*/ */
//TODO: NEED TO UPDATE WINDOWS IMPLEMENTATION ALSO!!!!!
func (r *Reporter) runLogProcessor() { func (r *Reporter) runLogProcessor() {
var err error var err error
r.tailer, err = tail.TailFile(r.LogFile, tail.Config{ r.tailer, err = tail.TailFile(r.LogFile, tail.Config{
Follow: true, Follow: true,
ReOpen: true, ReOpen: true,
Poll: true, // on linux we don't need to poll as the fsnotify works properly Poll: false, // on linux we don't need to poll as the fsnotify works properly
MustExist: true, MustExist: true,
}) })
if err != nil { if err != nil {
@ -120,7 +119,7 @@ func (r *Reporter) runLogProcessor() {
r.ReportingChannel <- report r.ReportingChannel <- report
} }
} }
case <- time.After(1 * time.Second): case <- time.After(100 * time.Millisecond):
if !r.running { if !r.running {
return return
} }

@ -7,10 +7,12 @@ import (
"log" "log"
"strconv" "strconv"
"strings" "strings"
"time"
) )
func (r *Reporter) runLogProcessor() { func (r *Reporter) runLogProcessor() {
tailer, err := tail.TailFile(r.LogFile, tail.Config{ var err error
r.tailer, err = tail.TailFile(r.LogFile, tail.Config{
Follow: true, Follow: true,
ReOpen: true, ReOpen: true,
Poll: true, Poll: true,
@ -19,8 +21,13 @@ func (r *Reporter) runLogProcessor() {
if err != nil { if err != nil {
log.Fatalf("failed to tail log file: %v", err) log.Fatalf("failed to tail log file: %v", err)
} }
for line := range tailer.Lines {
// TODO: For now this only cares about individual streams it ignores the sum lines for {
select {
case line := <- r.tailer.Lines:
if line == nil {
continue
}
if len(line.Text) > 5 { if len(line.Text) > 5 {
id := line.Text[1:4] id := line.Text[1:4]
stream, err := strconv.Atoi(strings.TrimSpace(id)) stream, err := strconv.Atoi(strings.TrimSpace(id))
@ -65,9 +72,10 @@ func (r *Reporter) runLogProcessor() {
r.ReportingChannel <- report r.ReportingChannel <- report
} }
} }
case <- time.After(100 * time.Millisecond):
if !r.running { if !r.running {
return return
} }
} }
}
} }

Loading…
Cancel
Save