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
002f3cff
Commit
002f3cff
authored
Sep 13, 2013
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api_create and api_start: work toward making them thread-safe
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
103a2fc0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
3 deletions
+30
-3
af_unix.c
src/lxc/af_unix.c
+5
-0
commands.c
src/lxc/commands.c
+5
-1
lxccontainer.c
src/lxc/lxccontainer.c
+6
-0
parse.c
src/lxc/parse.c
+5
-0
utils.c
src/lxc/utils.c
+9
-2
No files found.
src/lxc/af_unix.c
View file @
002f3cff
...
...
@@ -30,6 +30,7 @@
#include <sys/un.h>
#include "log.h"
#include "lxclock.h"
lxc_log_define
(
lxc_af_unix
,
lxc
);
...
...
@@ -100,7 +101,9 @@ int lxc_af_unix_connect(const char *path)
int
fd
;
struct
sockaddr_un
addr
;
process_lock
();
fd
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
process_unlock
();
if
(
fd
<
0
)
return
-
1
;
...
...
@@ -113,7 +116,9 @@ int lxc_af_unix_connect(const char *path)
if
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
)))
{
int
tmp
=
errno
;
process_lock
();
close
(
fd
);
process_unlock
();
errno
=
tmp
;
return
-
1
;
}
...
...
src/lxc/commands.c
View file @
002f3cff
...
...
@@ -46,6 +46,7 @@
#include "mainloop.h"
#include "af_unix.h"
#include "config.h"
#include "lxclock.h"
/*
* This file provides the different functions for clients to
...
...
@@ -282,8 +283,11 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
ret
=
lxc_cmd_rsp_recv
(
sock
,
cmd
);
out:
if
(
!
stay_connected
||
ret
<=
0
)
if
(
!
stay_connected
||
ret
<=
0
)
{
process_lock
();
close
(
sock
);
process_unlock
();
}
if
(
stay_connected
&&
ret
>
0
)
cmd
->
rsp
.
ret
=
sock
;
...
...
src/lxc/lxccontainer.c
View file @
002f3cff
...
...
@@ -665,7 +665,9 @@ static bool create_container_dir(struct lxc_container *c)
free
(
s
);
return
false
;
}
process_lock
();
ret
=
mkdir
(
s
,
0755
);
process_unlock
();
if
(
ret
)
{
if
(
errno
==
EEXIST
)
ret
=
0
;
...
...
@@ -1362,11 +1364,15 @@ static bool lxcapi_save_config(struct lxc_container *c, const char *alt_file)
if
(
lret
)
return
false
;
process_lock
();
fout
=
fopen
(
alt_file
,
"w"
);
process_unlock
();
if
(
!
fout
)
goto
out
;
write_config
(
fout
,
c
->
lxc_conf
);
process_lock
();
fclose
(
fout
);
process_unlock
();
ret
=
true
;
out:
...
...
src/lxc/parse.c
View file @
002f3cff
...
...
@@ -31,6 +31,7 @@
#include "parse.h"
#include "config.h"
#include "utils.h"
#include "lxclock.h"
#include <lxc/log.h>
/* Workaround for the broken signature of alphasort() in bionic.
...
...
@@ -90,7 +91,9 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
char
*
line
=
NULL
;
size_t
len
=
0
;
process_lock
();
f
=
fopen
(
file
,
"r"
);
process_unlock
();
if
(
!
f
)
{
SYSERROR
(
"failed to open %s"
,
file
);
return
-
1
;
...
...
@@ -104,7 +107,9 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
if
(
line
)
free
(
line
);
process_lock
();
fclose
(
f
);
process_unlock
();
return
err
;
}
...
...
src/lxc/utils.c
View file @
002f3cff
...
...
@@ -47,6 +47,7 @@
#include "utils.h"
#include "log.h"
#include "lxclock.h"
lxc_log_define
(
lxc_utils
,
lxc
);
...
...
@@ -409,7 +410,10 @@ int sha1sum_file(char *fnam, unsigned char *digest)
if
(
!
fnam
)
return
-
1
;
if
((
f
=
fopen_cloexec
(
fnam
,
"r"
))
<
0
)
{
process_lock
();
f
=
fopen_cloexec
(
fnam
,
"r"
);
process_unlock
();
if
(
f
<
0
)
{
SYSERROR
(
"Error opening template"
);
return
-
1
;
}
...
...
@@ -439,7 +443,10 @@ int sha1sum_file(char *fnam, unsigned char *digest)
fclose
(
f
);
return
-
1
;
}
if
(
fclose
(
f
)
<
0
)
{
process_lock
();
ret
=
fclose
(
f
);
process_unlock
();
if
(
ret
<
0
)
{
SYSERROR
(
"Failre closing template"
);
free
(
buf
);
return
-
1
;
...
...
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