Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7394c98d
Unverified
Commit
7394c98d
authored
Feb 11, 2021
by
Arve Knudsen
Committed by
GitHub
Feb 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MuxWriter: Handle error for already closed file (#31119)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent
5c9a10d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
pkg/infra/log/file.go
+12
-10
No files found.
pkg/infra/log/file.go
View file @
7394c98d
...
@@ -57,8 +57,8 @@ func (l *MuxWriter) Write(b []byte) (int, error) {
...
@@ -57,8 +57,8 @@ func (l *MuxWriter) Write(b []byte) (int, error) {
// set os.File in writer.
// set os.File in writer.
func
(
l
*
MuxWriter
)
setFD
(
fd
*
os
.
File
)
error
{
func
(
l
*
MuxWriter
)
setFD
(
fd
*
os
.
File
)
error
{
if
l
.
fd
!=
nil
{
if
l
.
fd
!=
nil
{
if
err
:=
l
.
fd
.
Close
();
err
!=
nil
{
if
err
:=
l
.
fd
.
Close
();
err
!=
nil
&&
!
errors
.
Is
(
err
,
os
.
ErrClosed
)
{
return
err
return
fmt
.
Errorf
(
"closing old file in MuxWriter failed: %w"
,
err
)
}
}
}
}
...
@@ -143,16 +143,18 @@ func (w *FileLogWriter) lineCounter() (int, error) {
...
@@ -143,16 +143,18 @@ func (w *FileLogWriter) lineCounter() (int, error) {
count
:=
0
count
:=
0
for
{
for
{
c
,
err
:=
r
.
Read
(
buf
)
c
,
err
:=
r
.
Read
(
buf
)
count
+=
bytes
.
Count
(
buf
[
:
c
],
[]
byte
{
'\n'
})
if
err
!=
nil
{
switch
{
if
errors
.
Is
(
err
,
io
.
EOF
)
{
case
errors
.
Is
(
err
,
io
.
EOF
)
:
if
err
:=
r
.
Close
();
err
!=
nil
&&
!
errors
.
Is
(
err
,
os
.
ErrClosed
)
{
if
err
:=
r
.
Close
();
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"closing %q failed: %w"
,
w
.
Filename
,
err
)
return
count
,
err
}
return
count
,
nil
}
}
return
count
,
nil
case
err
!=
nil
:
return
0
,
err
return
count
,
err
}
}
count
+=
bytes
.
Count
(
buf
[
:
c
],
[]
byte
{
'\n'
})
}
}
}
}
...
...
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