s-urbaniak / uevent Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
The project documentation shows a way to use uevent
library as:
dec := uevent.NewDecoder(r)
for {
evt, err := dec.Decode()
if err != nil {
log.Fatal(err)
}
fmt.Println(evt)
}
I have an app with a goroutine that does this loop. Now I need to stop my application and shutdown the loop. Unfortunately there is no way to do it gracefully. I can do uevent.Close()
in another goroutine but it is racy and causes a panic in bufio.Reader
(see anatol/booster#22):
panic: bufio: reader returned negative count from Read
goroutine 6 [running]:
bufio.(*Reader).fill(0xc000070f68)
/usr/lib/go/src/bufio/bufio.go:103 +0x1dd
bufio.(*Reader).ReadSlice(0xc000070f68, 0x0, 0xc, 0x7f6718544c28, 0xc0003c42f0, 0x0, 0xab0fc0)
/usr/lib/go/src/bufio/bufio.go:360 +0x3d
bufio.(*Reader).collectFragments(0xc000070f68, 0xc000070d00, 0x40d610, 0xc00006b440, 0x30, 0x30, 0x823120, 0xc00005c960, 0x60, 0x7f671854e308, ...)
/usr/lib/go/src/bufio/bufio.go:435 +0x7a
bufio.(*Reader).ReadString(0xc000070f68, 0xc00005c900, 0x7, 0x0, 0xc00011a9d8, 0x0)
/usr/lib/go/src/bufio/bufio.go:483 +0x4c
github.com/s-urbaniak/uevent.(*Decoder).next(...)
/home/anatol/go/pkg/mod/github.com/s-urbaniak/[email protected]/decoder.go:81
github.com/s-urbaniak/uevent.(*Decoder).Decode(0xc000070ed0, 0xc00006b3e0, 0x83cf0f, 0x7)
/home/anatol/go/pkg/mod/github.com/s-urbaniak/[email protected]/decoder.go:42 +0x75
main.udevListener()
/mnt/cold/sources/golang/booster/init/main.go:454 +0x185
created by main.boost
/mnt/cold/sources/golang/booster/init/main.go:782 +0x4bd
Please provide a way to shutdown the uevent loop gracefully.
The Apache 2 license is a good choice, or the BSD-style license that Go itself is released under (https://golang.org/LICENSE).
Thank you for the useful package!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.