diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-01-16 12:03:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 12:03:31 -0500 |
commit | 2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7 (patch) | |
tree | e08ff912e1924c06939f314168c3362d6f1ec0de /vendor/github.com/miekg/dns/scanner.go | |
parent | f5c8a71698d0a7a16c68be220e49fe64bfee7f5c (diff) | |
download | chat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.tar.gz chat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.tar.bz2 chat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.zip |
Updated dependencies and added avct/uasurfer (#8089)
* Updated dependencies and added avct/uasurfer
* Added uasurfer to NOTICE.txt
Diffstat (limited to 'vendor/github.com/miekg/dns/scanner.go')
-rw-r--r-- | vendor/github.com/miekg/dns/scanner.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/vendor/github.com/miekg/dns/scanner.go b/vendor/github.com/miekg/dns/scanner.go index c29bc2f38..424e5af9f 100644 --- a/vendor/github.com/miekg/dns/scanner.go +++ b/vendor/github.com/miekg/dns/scanner.go @@ -4,6 +4,7 @@ package dns import ( "bufio" + "context" "io" "text/scanner" ) @@ -12,13 +13,18 @@ type scan struct { src *bufio.Reader position scanner.Position eof bool // Have we just seen a eof + ctx context.Context } -func scanInit(r io.Reader) *scan { +func scanInit(r io.Reader) (*scan, context.CancelFunc) { s := new(scan) s.src = bufio.NewReader(r) s.position.Line = 1 - return s + + ctx, cancel := context.WithCancel(context.Background()) + s.ctx = ctx + + return s, cancel } // tokenText returns the next byte from the input @@ -27,6 +33,13 @@ func (s *scan) tokenText() (byte, error) { if err != nil { return c, err } + select { + case <-s.ctx.Done(): + return c, context.Canceled + default: + break + } + // delay the newline handling until the next token is delivered, // fixes off-by-one errors when reporting a parse error. if s.eof == true { |