[ARVADOS] updated: f10431fe2de1037c3c0d51d8238cecf6c1206703

Git user git at public.curoverse.com
Thu May 4 13:02:47 EDT 2017


Summary of changes:
 services/crunch-run/logging.go | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

       via  f10431fe2de1037c3c0d51d8238cecf6c1206703 (commit)
      from  e54bce82515daeef450f53aa93d3acae397bfa5f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f10431fe2de1037c3c0d51d8238cecf6c1206703
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu May 4 13:02:40 2017 -0400

    8019: Use tl.stopping channel instead of tl.flush to signal Close. Use unbuffered channel to signal flush.

diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 3aedf51..96feb5f 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -34,9 +34,10 @@ type ThrottledLogger struct {
 	*log.Logger
 	buf *bytes.Buffer
 	sync.Mutex
-	writer  io.WriteCloser
-	flush   chan struct{}
-	stopped chan struct{}
+	writer   io.WriteCloser
+	flush    chan struct{}
+	stopped  chan struct{}
+	stopping chan struct{}
 	Timestamper
 	Immediate    *log.Logger
 	pendingFlush bool
@@ -97,9 +98,10 @@ func (tl *ThrottledLogger) flusher() {
 	defer ticker.Stop()
 	for stopping := false; !stopping; {
 		select {
-		case _, open := <-tl.flush:
-			// if !open, will flush tl.buf and exit the loop
-			stopping = !open
+		case <-tl.stopping:
+			// flush tl.buf and exit the loop
+			stopping = true
+		case <-tl.flush:
 		case <-ticker.C:
 		}
 
@@ -120,10 +122,10 @@ func (tl *ThrottledLogger) flusher() {
 // underlying Writer.
 func (tl *ThrottledLogger) Close() error {
 	select {
-	case <-tl.flush:
+	case <-tl.stopping:
 		// already stopped
 	default:
-		close(tl.flush)
+		close(tl.stopping)
 	}
 	<-tl.stopped
 	return tl.writer.Close()
@@ -173,8 +175,9 @@ func ReadWriteLines(in io.Reader, writer io.Writer, done chan<- bool) {
 //  at most once per "crunchLogSecondsBetweenEvents" seconds.
 func NewThrottledLogger(writer io.WriteCloser) *ThrottledLogger {
 	tl := &ThrottledLogger{}
-	tl.flush = make(chan struct{}, 1)
+	tl.flush = make(chan struct{})
 	tl.stopped = make(chan struct{})
+	tl.stopping = make(chan struct{})
 	tl.writer = writer
 	tl.Logger = log.New(tl, "", 0)
 	tl.Timestamper = RFC3339Timestamp

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list