Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
3cdd9dc4
Commit
3cdd9dc4
authored
Apr 11, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use syncrounous IO for log writer
parent
28eeccf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
HTTPServer.pm
PVE/HTTPServer.pm
+21
-16
No files found.
PVE/HTTPServer.pm
View file @
3cdd9dc4
...
...
@@ -43,8 +43,6 @@ my $known_methods = {
sub
log_request
{
my
(
$self
,
$reqstate
)
=
@_
;
return
if
!
$self
->
{
loghdl
};
my
$loginfo
=
$reqstate
->
{
log
};
# like apache2 common log format
...
...
@@ -59,7 +57,7 @@ sub log_request {
my
$msg
=
"
$peerip
-
$userid
[
$timestr
]
\"
$requestline
\"
$code
$content_length
\n
";
$self
->
{
loghdl
}
->
push_write
(
$msg
);
$self
->
write_log
(
$msg
);
}
sub
log_aborted_request
{
...
...
@@ -696,6 +694,9 @@ sub accept_connections {
$self
->
wait_end_loop
()
if
$self
->
{
end_loop
};
}
# Note: We can't open log file in non-blocking mode and use AnyEvent::Handle,
# because we write from multiple processes, and that would arbitrarily mix output
# of all processes.
sub
open_access_log
{
my
(
$self
,
$filename
)
=
@_
;
...
...
@@ -704,18 +705,23 @@ sub open_access_log {
die
"
unable to open log file '
$filename
' - $!
\n
";
umask
(
$old_mask
);
fh_nonblocking
(
$logfh
,
1
);
$self
->
{
loghdl
}
=
AnyEvent::
Handle
->
new
(
fh
=>
$logfh
,
on_error
=>
sub
{
my
(
$hdl
,
$fatal
,
$msg
)
=
@_
;
syslog
('
err
',
"
error writing access log:
$msg
");
delete
$self
->
{
loghdl
};
$hdl
->
destroy
;
$self
->
{
end_loop
}
=
1
;
# terminate asap
});;
return
;
$logfh
->
autoflush
(
1
);
$self
->
{
logfh
}
=
$logfh
;
}
sub
write_log
{
my
(
$self
,
$data
)
=
@_
;
return
if
!
defined
(
$self
->
{
logfh
})
||
!
$data
;
my
$res
=
$self
->
{
logfh
}
->
print
(
$data
);
if
(
!
$res
)
{
delete
$self
->
{
logfh
};
syslog
('
err
',
"
error writing access log
");
$self
->
{
end_loop
}
=
1
;
# terminate asap
}
}
sub
new
{
...
...
@@ -745,7 +751,6 @@ sub new {
$self
->
{
tls_ctx
}
=
AnyEvent::
TLS
->
new
(
%
{
$self
->
{
ssl
}});
}
# fixme: logrotate?
$self
->
open_access_log
(
$self
->
{
logfile
})
if
$self
->
{
logfile
};
$self
->
{
socket_watch
}
=
AnyEvent
->
io
(
fh
=>
$self
->
{
socket
},
poll
=>
'
r
',
cb
=>
sub
{
...
...
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