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
32036de0
Commit
32036de0
authored
Apr 08, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #954 from brauner/2016-04-08/lxc_attach_simplify_and_log
use lxc_read_nointr() and lxc_write_nointr()
parents
6a874d31
e66b6c96
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
34 deletions
+18
-34
console.c
src/lxc/console.c
+15
-33
lxc_attach.c
src/lxc/lxc_attach.c
+3
-1
No files found.
src/lxc/console.c
View file @
32036de0
...
@@ -161,33 +161,25 @@ static int lxc_console_cb_con(int fd, uint32_t events, void *data,
...
@@ -161,33 +161,25 @@ static int lxc_console_cb_con(int fd, uint32_t events, void *data,
{
{
struct
lxc_console
*
console
=
(
struct
lxc_console
*
)
data
;
struct
lxc_console
*
console
=
(
struct
lxc_console
*
)
data
;
char
buf
[
1024
];
char
buf
[
1024
];
int
r
,
w
;
int
r
,
w
;
if
(
events
&
EPOLLHUP
)
return
1
;
w
=
r
=
read
(
fd
,
buf
,
sizeof
(
buf
));
if
(
r
<
0
)
{
SYSERROR
(
"failed to read"
);
return
1
;
}
if
(
!
r
)
{
w
=
r
=
lxc_read_nointr
(
fd
,
buf
,
sizeof
(
buf
));
if
(
r
<=
0
)
{
INFO
(
"console client on fd %d has exited"
,
fd
);
INFO
(
"console client on fd %d has exited"
,
fd
);
lxc_mainloop_del_handler
(
descr
,
fd
);
lxc_mainloop_del_handler
(
descr
,
fd
);
close
(
fd
);
close
(
fd
);
return
0
;
return
1
;
}
}
if
(
fd
==
console
->
peer
)
if
(
fd
==
console
->
peer
)
w
=
write
(
console
->
master
,
buf
,
r
);
w
=
lxc_write_nointr
(
console
->
master
,
buf
,
r
);
if
(
fd
==
console
->
master
)
{
if
(
fd
==
console
->
master
)
{
if
(
console
->
log_fd
>=
0
)
if
(
console
->
log_fd
>=
0
)
w
=
write
(
console
->
log_fd
,
buf
,
r
);
w
=
lxc_write_nointr
(
console
->
log_fd
,
buf
,
r
);
if
(
console
->
peer
>=
0
)
if
(
console
->
peer
>=
0
)
w
=
write
(
console
->
peer
,
buf
,
r
);
w
=
lxc_write_nointr
(
console
->
peer
,
buf
,
r
);
}
}
if
(
w
!=
r
)
if
(
w
!=
r
)
...
@@ -579,14 +571,9 @@ int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
...
@@ -579,14 +571,9 @@ int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
struct
lxc_tty_state
*
ts
=
cbdata
;
struct
lxc_tty_state
*
ts
=
cbdata
;
char
c
;
char
c
;
if
(
events
&
EPOLLHUP
)
return
1
;
assert
(
fd
==
ts
->
stdinfd
);
assert
(
fd
==
ts
->
stdinfd
);
if
(
read
(
ts
->
stdinfd
,
&
c
,
1
)
<
0
)
{
if
(
lxc_read_nointr
(
ts
->
stdinfd
,
&
c
,
1
)
<=
0
)
SYSERROR
(
"failed to read"
);
return
1
;
return
1
;
}
if
(
ts
->
escape
!=
-
1
)
{
if
(
ts
->
escape
!=
-
1
)
{
/* we want to exit the console with Ctrl+a q */
/* we want to exit the console with Ctrl+a q */
...
@@ -601,10 +588,8 @@ int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
...
@@ -601,10 +588,8 @@ int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
ts
->
saw_escape
=
0
;
ts
->
saw_escape
=
0
;
}
}
if
(
write
(
ts
->
masterfd
,
&
c
,
1
)
<
0
)
{
if
(
lxc_write_nointr
(
ts
->
masterfd
,
&
c
,
1
)
<=
0
)
SYSERROR
(
"failed to write"
);
return
1
;
return
1
;
}
return
0
;
return
0
;
}
}
...
@@ -616,18 +601,15 @@ int lxc_console_cb_tty_master(int fd, uint32_t events, void *cbdata,
...
@@ -616,18 +601,15 @@ int lxc_console_cb_tty_master(int fd, uint32_t events, void *cbdata,
char
buf
[
1024
];
char
buf
[
1024
];
int
r
,
w
;
int
r
,
w
;
if
(
events
&
EPOLLHUP
)
return
1
;
assert
(
fd
==
ts
->
masterfd
);
assert
(
fd
==
ts
->
masterfd
);
r
=
read
(
fd
,
buf
,
sizeof
(
buf
));
r
=
lxc_read_nointr
(
fd
,
buf
,
sizeof
(
buf
));
if
(
r
<
0
)
{
if
(
r
<=
0
)
SYSERROR
(
"failed to read"
);
return
1
;
return
1
;
}
w
=
write
(
ts
->
stdoutfd
,
buf
,
r
);
w
=
lxc_write_nointr
(
ts
->
stdoutfd
,
buf
,
r
);
if
(
w
<
0
||
w
!=
r
)
{
if
(
w
<=
0
)
{
return
1
;
}
else
if
(
w
!=
r
)
{
SYSERROR
(
"failed to write"
);
SYSERROR
(
"failed to write"
);
return
1
;
return
1
;
}
}
...
...
src/lxc/lxc_attach.c
View file @
32036de0
...
@@ -301,8 +301,10 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
...
@@ -301,8 +301,10 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
goto
err2
;
goto
err2
;
}
}
if
(
lxc_console_mainloop_add
(
&
descr
,
conf
)
<
0
)
if
(
lxc_console_mainloop_add
(
&
descr
,
conf
)
<
0
)
{
ERROR
(
"Failed to add handlers to lxc mainloop."
);
goto
err3
;
goto
err3
;
}
ret
=
lxc_mainloop
(
&
descr
,
-
1
);
ret
=
lxc_mainloop
(
&
descr
,
-
1
);
if
(
ret
)
{
if
(
ret
)
{
...
...
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