Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
928aa7a0
Commit
928aa7a0
authored
Mar 28, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply the same async and zodbpickle fixes to the ZEO4 server.
parent
b3ee072b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
src/ZEO/tests/ZEO4/zrpc/connection.py
src/ZEO/tests/ZEO4/zrpc/connection.py
+10
-10
src/ZEO/tests/ZEO4/zrpc/marshal.py
src/ZEO/tests/ZEO4/zrpc/marshal.py
+8
-3
No files found.
src/ZEO/tests/ZEO4/zrpc/connection.py
View file @
928aa7a0
...
...
@@ -418,10 +418,10 @@ class Connection(smac.SizedMessageAsyncConnection, object):
# will raise an exception. The exception will ultimately
# result in asycnore calling handle_error(), which will
# close the connection.
msgid
,
async
,
name
,
args
=
self
.
decode
(
message
)
msgid
,
async
_
,
name
,
args
=
self
.
decode
(
message
)
if
debug_zrpc
:
self
.
log
(
"recv msg: %s, %s, %s, %s"
%
(
msgid
,
async
,
name
,
self
.
log
(
"recv msg: %s, %s, %s, %s"
%
(
msgid
,
async
_
,
name
,
short_repr
(
args
)),
level
=
TRACE
)
...
...
@@ -446,12 +446,12 @@ class Connection(smac.SizedMessageAsyncConnection, object):
self
.
send_reply
(
msgid
,
ret
)
elif
name
==
REPLY
:
assert
not
async
assert
not
async
_
self
.
handle_reply
(
msgid
,
args
)
else
:
self
.
handle_request
(
msgid
,
async
,
name
,
args
)
self
.
handle_request
(
msgid
,
async
_
,
name
,
args
)
def
handle_request
(
self
,
msgid
,
async
,
name
,
args
):
def
handle_request
(
self
,
msgid
,
async
_
,
name
,
args
):
obj
=
self
.
obj
if
name
.
startswith
(
'_'
)
or
not
hasattr
(
obj
,
name
):
...
...
@@ -482,14 +482,14 @@ class Connection(smac.SizedMessageAsyncConnection, object):
self
.
log
(
"%s() raised exception: %s"
%
(
name
,
msg
),
logging
.
ERROR
,
exc_info
=
True
)
error
=
sys
.
exc_info
()[:
2
]
if
async
:
if
async
_
:
self
.
log
(
"Asynchronous call raised exception: %s"
%
self
,
level
=
logging
.
ERROR
,
exc_info
=
True
)
else
:
self
.
return_error
(
msgid
,
*
error
)
return
if
async
:
if
async
_
:
if
ret
is
not
None
:
raise
ZRPCError
(
"async method %s returned value %s"
%
(
name
,
short_repr
(
ret
)))
...
...
@@ -545,15 +545,15 @@ class Connection(smac.SizedMessageAsyncConnection, object):
def
send_call
(
self
,
method
,
args
,
async_
=
False
):
# send a message and return its msgid
if
async
:
if
async
_
:
msgid
=
0
else
:
msgid
=
self
.
_new_msgid
()
if
debug_zrpc
:
self
.
log
(
"send msg: %d, %d, %s, ..."
%
(
msgid
,
async
,
method
),
self
.
log
(
"send msg: %d, %d, %s, ..."
%
(
msgid
,
async
_
,
method
),
level
=
TRACE
)
buf
=
self
.
encode
(
msgid
,
async
,
method
,
args
)
buf
=
self
.
encode
(
msgid
,
async
_
,
method
,
args
)
self
.
message_output
(
buf
)
return
msgid
...
...
src/ZEO/tests/ZEO4/zrpc/marshal.py
View file @
928aa7a0
...
...
@@ -17,6 +17,8 @@ from ZEO._compat import Unpickler, Pickler, BytesIO, PY3, PYPY
from
.error
import
ZRPCError
from
.log
import
log
,
short_repr
PY2
=
not
PY3
def
encode
(
*
args
):
# args: (msgid, flags, name, args)
# (We used to have a global pickler, but that's not thread-safe. :-( )
...
...
@@ -106,6 +108,8 @@ _silly = ('__doc__',)
exception_type_type
=
type
(
Exception
)
_SAFE_MODULE_NAMES
=
(
'ZopeUndo.Prefix'
,
'copy_reg'
,
'__builtin__'
,
'zodbpickle'
)
def
find_global
(
module
,
name
):
"""Helper for message unpickler"""
try
:
...
...
@@ -118,7 +122,7 @@ def find_global(module, name):
except
AttributeError
:
raise
ZRPCError
(
"module %s has no global %s"
%
(
module
,
name
))
safe
=
getattr
(
r
,
'__no_side_effects__'
,
0
)
safe
=
getattr
(
r
,
'__no_side_effects__'
,
0
)
or
(
PY2
and
module
in
_SAFE_MODULE_NAMES
)
if
safe
:
return
r
...
...
@@ -130,9 +134,10 @@ def find_global(module, name):
def
server_find_global
(
module
,
name
):
"""Helper for message unpickler"""
if
module
not
in
_SAFE_MODULE_NAMES
:
raise
ImportError
(
"Module not allowed: %s"
%
(
module
,))
try
:
if
module
!=
'ZopeUndo.Prefix'
:
raise
ImportError
m
=
__import__
(
module
,
_globals
,
_globals
,
_silly
)
except
ImportError
as
msg
:
raise
ZRPCError
(
"import error %s: %s"
%
(
module
,
msg
))
...
...
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