Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
89cb4303
Commit
89cb4303
authored
9 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix mirrorWriter write
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
67be6bbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
thirdparty/eventlog/writer.go
thirdparty/eventlog/writer.go
+20
-5
No files found.
thirdparty/eventlog/writer.go
View file @
89cb4303
...
...
@@ -12,14 +12,29 @@ type MirrorWriter struct {
func
(
mw
*
MirrorWriter
)
Write
(
b
[]
byte
)
(
int
,
error
)
{
mw
.
lk
.
Lock
()
var
filter
[]
io
.
Writer
for
_
,
w
:=
range
mw
.
writers
{
// write to all writers, and nil out the broken ones.
for
i
,
w
:=
range
mw
.
writers
{
_
,
err
:=
w
.
Write
(
b
)
if
err
=
=
nil
{
filter
=
append
(
filter
,
w
)
if
err
!
=
nil
{
mw
.
writers
[
i
]
=
nil
}
}
mw
.
writers
=
filter
// consolidate the slice
for
i
:=
0
;
i
<
len
(
mw
.
writers
);
i
++
{
if
mw
.
writers
[
i
]
!=
nil
{
continue
}
j
:=
len
(
mw
.
writers
)
for
;
j
>
i
;
j
--
{
if
mw
.
writers
[
j
]
!=
nil
{
mw
.
writers
[
i
],
mw
.
writers
[
j
]
=
mw
.
writers
[
j
],
nil
// swap
break
}
}
mw
.
writers
=
mw
.
writers
[
:
j
]
}
mw
.
lk
.
Unlock
()
return
len
(
b
),
nil
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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