Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
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
Jérome Perrin
neoppod
Commits
bf2c5aee
Commit
bf2c5aee
authored
Mar 20, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not notify about malformed packet in order to avoid bounces
parent
4f1b6c28
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
20 deletions
+16
-20
neo/lib/connection.py
neo/lib/connection.py
+6
-7
neo/lib/handler.py
neo/lib/handler.py
+4
-6
neo/tests/testConnection.py
neo/tests/testConnection.py
+5
-5
neo/tests/testHandler.py
neo/tests/testHandler.py
+1
-2
No files found.
neo/lib/connection.py
View file @
bf2c5aee
...
...
@@ -499,16 +499,15 @@ class Connection(BaseConnection):
def
analyse
(
self
):
"""Analyse received data."""
while
True
:
# parse a packet
try
:
try
:
while
True
:
packet
=
Packets
.
parse
(
self
.
read_buf
,
self
.
_parser_state
)
if
packet
is
None
:
break
except
PacketMalformedError
,
msg
:
self
.
getHandler
().
_packetMalformed
(
self
,
msg
)
return
self
.
_
queue
.
append
(
packet
)
self
.
_queue
.
append
(
packet
)
except
PacketMalformedError
,
e
:
logging
.
error
(
'malformed packet from %r: %s'
,
self
,
e
)
self
.
_
closure
(
)
def
hasPendingMessages
(
self
):
"""
...
...
neo/lib/handler.py
View file @
bf2c5aee
...
...
@@ -56,12 +56,10 @@ class EventHandler(object):
except
UnexpectedPacketError
,
e
:
if
not
conn
.
isClosed
():
self
.
__unexpectedPacket
(
conn
,
packet
,
*
e
.
args
)
except
PacketMalformedError
:
if
not
conn
.
isClosed
():
logging
.
error
(
'malformed packet from %r'
,
conn
)
conn
.
notify
(
Packets
.
Notify
(
'Malformed packet: %r'
%
(
packet
,
)))
conn
.
abort
()
# self.peerBroken(conn)
except
PacketMalformedError
,
e
:
logging
.
error
(
'malformed packet from %r: %s'
,
conn
,
e
)
conn
.
close
()
# self.peerBroken(conn)
except
BrokenNodeDisallowedError
:
if
not
conn
.
isClosed
():
conn
.
answer
(
Errors
.
BrokenNode
(
'go away'
))
...
...
neo/tests/testConnection.py
View file @
bf2c5aee
...
...
@@ -477,12 +477,12 @@ class ConnectionTests(NeoUnitTestBase):
def
test_Connection_analyse3
(
self
):
# give a bad packet, won't be decoded
bc
=
self
.
_makeConnection
()
bc
.
_queue
=
Mock
()
self
.
_appendToReadBuf
(
bc
,
'datadatadatadata'
)
p
=
Packets
.
Ping
()
p
.
setId
(
1
)
self
.
_appendToReadBuf
(
bc
,
'%s%sdatadatadatadata'
%
p
.
encode
())
bc
.
analyse
()
self
.
assertEqual
(
len
(
bc
.
_queue
.
mockGetNamedCalls
(
"append"
)),
0
)
self
.
assertEqual
(
len
(
self
.
handler
.
mockGetNamedCalls
(
"_packetMalformed"
)),
1
)
self
.
_checkPacketReceived
(
1
)
# ping packet
self
.
_checkClose
(
1
)
# malformed packet
def
test_Connection_analyse4
(
self
):
# give an expected packet
...
...
neo/tests/testHandler.py
View file @
bf2c5aee
...
...
@@ -59,8 +59,7 @@ class HandlerTests(NeoUnitTestBase):
raise
PacketMalformedError
(
'message'
)
self
.
setFakeMethod
(
fake
)
self
.
handler
.
dispatch
(
conn
,
packet
)
self
.
checkNotify
(
conn
)
self
.
checkAborted
(
conn
)
self
.
checkClosed
(
conn
)
# raise BrokenNodeDisallowedError
conn
.
mockCalledMethods
=
{}
def
fake
(
c
):
...
...
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