Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
160cdf80
Unverified
Commit
160cdf80
authored
6 years ago
by
Nick Ethier
Browse files
Options
Download
Email Patches
Plain Diff
circbufwriter: defer unlock in Write since it will not block
parent
c6cc1e62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/circbufwriter/writer.go
+5
-2
lib/circbufwriter/writer.go
with
5 additions
and
2 deletions
+5
-2
lib/circbufwriter/writer.go
+
5
-
2
View file @
160cdf80
...
...
@@ -43,15 +43,18 @@ func New(w io.Writer, bufferSize int64) io.WriteCloser {
// the wrapped writer. If the wrapped writer blocks on write, subsequent write
// will be written to the circle buffer.
func
(
c
*
circbufWriter
)
Write
(
p
[]
byte
)
(
nn
int
,
err
error
)
{
// If the last write returned an error, return it here
// If the last write returned an error, return it here. Note there is a
// small chance of missing an error if multiple writes occure at the same
// time where the last write nils out the error before it can be returned
// here.
c
.
bufLock
.
Lock
()
defer
c
.
bufLock
.
Unlock
()
if
c
.
err
!=
nil
{
return
nn
,
c
.
err
}
// Write to the buffer
nn
,
err
=
c
.
buf
.
Write
(
p
)
c
.
bufLock
.
Unlock
()
// Signal to flush the buffer
select
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help