Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
3f924551
Unverified
Commit
3f924551
authored
May 13, 2020
by
Christian Brauner
Committed by
Stéphane Graber
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: cleanup syslog handling
Disable and enable syslog around lxc_check_inherited(). Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e758df85
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
12 deletions
+28
-12
log.c
src/lxc/log.c
+9
-4
log.h
src/lxc/log.h
+2
-1
start.c
src/lxc/start.c
+17
-7
No files found.
src/lxc/log.c
View file @
3f924551
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#define LXC_LOG_TIME_SIZE ((INTTYPE_TO_STRLEN(uint64_t)) * 2)
#define LXC_LOG_TIME_SIZE ((INTTYPE_TO_STRLEN(uint64_t)) * 2)
int
lxc_log_fd
=
-
EBADF
;
int
lxc_log_fd
=
-
EBADF
;
static
int
syslog_enable
=
0
;
static
bool
wants_syslog
=
false
;
int
lxc_quiet_specified
;
int
lxc_quiet_specified
;
int
lxc_log_use_global_fd
;
int
lxc_log_use_global_fd
;
static
int
lxc_loglevel_specified
;
static
int
lxc_loglevel_specified
;
...
@@ -128,7 +128,7 @@ static int log_append_syslog(const struct lxc_log_appender *appender,
...
@@ -128,7 +128,7 @@ static int log_append_syslog(const struct lxc_log_appender *appender,
__do_free
char
*
msg
=
NULL
;
__do_free
char
*
msg
=
NULL
;
const
char
*
log_container_name
;
const
char
*
log_container_name
;
if
(
!
syslog_enable
)
if
(
!
wants_syslog
)
return
0
;
return
0
;
log_container_name
=
lxc_log_get_container_name
();
log_container_name
=
lxc_log_get_container_name
();
...
@@ -738,9 +738,14 @@ int lxc_log_syslog(int facility)
...
@@ -738,9 +738,14 @@ int lxc_log_syslog(int facility)
return
0
;
return
0
;
}
}
inline
void
lxc_log_enable_syslog
(
void
)
void
lxc_log_syslog_enable
(
void
)
{
{
syslog_enable
=
1
;
wants_syslog
=
true
;
}
void
lxc_log_syslog_disable
(
void
)
{
wants_syslog
=
false
;
}
}
/*
/*
...
...
src/lxc/log.h
View file @
3f924551
...
@@ -563,7 +563,8 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
...
@@ -563,7 +563,8 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
extern
int
lxc_log_fd
;
extern
int
lxc_log_fd
;
extern
int
lxc_log_syslog
(
int
facility
);
extern
int
lxc_log_syslog
(
int
facility
);
extern
void
lxc_log_enable_syslog
(
void
);
extern
void
lxc_log_syslog_enable
(
void
);
extern
void
lxc_log_syslog_disable
(
void
);
extern
int
lxc_log_set_level
(
int
*
dest
,
int
level
);
extern
int
lxc_log_set_level
(
int
*
dest
,
int
level
);
extern
int
lxc_log_get_level
(
void
);
extern
int
lxc_log_get_level
(
void
);
extern
bool
lxc_log_has_valid_level
(
void
);
extern
bool
lxc_log_has_valid_level
(
void
);
...
...
src/lxc/start.c
View file @
3f924551
...
@@ -212,6 +212,13 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
...
@@ -212,6 +212,13 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
if
(
conf
&&
conf
->
close_all_fds
)
if
(
conf
&&
conf
->
close_all_fds
)
closeall
=
true
;
closeall
=
true
;
/*
* Disable syslog at this point to avoid the above logging
* function to open a new fd and make the check_inherited function
* enter an infinite loop.
*/
lxc_log_syslog_disable
();
restart:
restart:
dir
=
opendir
(
"/proc/self/fd"
);
dir
=
opendir
(
"/proc/self/fd"
);
if
(
!
dir
)
if
(
!
dir
)
...
@@ -272,21 +279,24 @@ restart:
...
@@ -272,21 +279,24 @@ restart:
#endif
#endif
if
(
closeall
)
{
if
(
closeall
)
{
close
(
fd
);
if
(
close
(
fd
))
SYSINFO
(
"Closed inherited fd %d"
,
fd
);
else
INFO
(
"Closed inherited fd %d"
,
fd
);
closedir
(
dir
);
closedir
(
dir
);
INFO
(
"Closed inherited fd %d"
,
fd
);
goto
restart
;
goto
restart
;
}
}
WARN
(
"Inherited fd %d"
,
fd
);
WARN
(
"Inherited fd %d"
,
fd
);
}
}
closedir
(
dir
);
/* Only enable syslog at this point to avoid the above logging function
/*
* to open a new fd and make the check_inherited function enter an
* Only enable syslog at this point to avoid the above logging
* infinite loop.
* function to open a new fd and make the check_inherited function
* enter an infinite loop.
*/
*/
lxc_log_
enable_syslog
();
lxc_log_
syslog_enable
();
closedir
(
dir
);
/* cannot fail */
return
0
;
return
0
;
}
}
...
...
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