Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
8c9c6a05
Commit
8c9c6a05
authored
Jun 18, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some silly bugs
parent
5e1f40d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
src/netns/protocol.py
src/netns/protocol.py
+9
-8
No files found.
src/netns/protocol.py
View file @
8c9c6a05
...
...
@@ -80,7 +80,7 @@ class Server(object):
self
.
f
=
fd
else
:
if
hasattr
(
fd
,
"makefile"
):
self
.
f
=
fd
.
makefile
(
fd
,
"r+"
,
1
)
# line buffered
self
.
f
=
fd
.
makefile
(
"r+"
,
1
)
# line buffered
else
:
self
.
f
=
os
.
fdopen
(
fd
,
"r+"
,
1
)
...
...
@@ -350,10 +350,10 @@ def _start_child():
s
=
"Slave node aborting: %s
\
n
"
%
str
(
e
)
try
:
# try to pass the error to parent, if possible
s
0
.
write
(
"500 "
+
e
)
s
1
.
send
(
"500 "
+
s
)
except
:
pass
sys
.
stderr
.
write
(
e
)
sys
.
stderr
.
write
(
s
)
os
.
_exit
(
1
)
# Try block just in case...
...
...
@@ -366,7 +366,8 @@ def _start_child():
# NOTREACHED
class
Slave
(
object
):
"""Class to create and manage slave processes."""
"""Class to create and manage slave processes; it is at the same time a
client implementation for the communication protocol."""
def
__init__
(
self
,
fd
=
None
,
pid
=
None
):
"""When called without arguments, it will fork, create a new network
namespace and enter a loop to serve requests from the master. The
...
...
@@ -396,14 +397,14 @@ class Slave(object):
def
_send_cmd
(
self
,
*
args
):
s
=
" "
.
join
(
map
(
str
,
args
))
+
"
\
n
"
self
.
f
.
write
(
s
)
self
.
_fd
.
write
(
s
)
def
_read_reply
(
self
):
"""Reads a (possibly multi-line) response from the server. Returns a
tuple containing (code, text)"""
text
=
""
while
True
:
line
=
self
.
f
.
readline
().
rstrip
()
line
=
self
.
_fd
.
readline
().
rstrip
()
if
not
line
:
raise
RuntimeError
(
"Protocol error, empty line received"
)
...
...
@@ -422,7 +423,7 @@ class Slave(object):
defaults to 2."""
code
,
text
=
self
.
_read_reply
()
if
code
/
100
!=
expected
:
raise
"Error on command: %d %s"
%
(
code
,
text
)
raise
RuntimeError
(
"Error from slave: %d %s"
%
(
code
,
text
)
)
return
text
def
shutdown
(
self
):
...
...
@@ -434,7 +435,7 @@ class Slave(object):
"Pass a file descriptor"
self
.
_send_cmd
(
"PROC"
,
type
)
self
.
_read_and_check_reply
(
3
)
passfd
.
sendfd
(
self
.
f
.
fileno
(),
fd
,
"PROC "
+
type
)
passfd
.
sendfd
(
self
.
_fd
.
fileno
(),
fd
,
"PROC "
+
type
)
self
.
_read_and_check_reply
()
def
popen
(
self
,
uid
,
gid
,
file
,
argv
=
None
,
cwd
=
None
,
env
=
None
,
...
...
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