Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
smbprotocol-readonly
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Merlin Sievers
smbprotocol-readonly
Commits
a09cb496
Unverified
Commit
a09cb496
authored
Feb 21, 2018
by
Jordan Borean
Browse files
Options
Downloads
Patches
Plain Diff
fixed issue while waiting for sock buffer to be complete
parent
9572a702
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
smbprotocol/transport.py
+21
-11
21 additions, 11 deletions
smbprotocol/transport.py
with
21 additions
and
11 deletions
smbprotocol/transport.py
+
21
−
11
View file @
a09cb496
...
...
@@ -84,18 +84,28 @@ class Tcp(object):
def
receive
(
self
):
# receive first 4 bytes that contain the size of the packet, return
# None if no data is available, Connection handles this scenario
packet_size_bytes
=
self
.
_recv
(
4
)
if
packet_size_bytes
is
None
:
return
packet_size_int
=
struct
.
unpack
(
"
>L
"
,
packet_size_bytes
)[
0
]
buffer
=
self
.
_recv
(
packet_size_int
)
return
buffer
def
_recv
(
self
,
buffer
):
# will attempt to retrieve the data in the recv buffer based on the
# buffer size or return None if nothing available
bytes
=
b
""
while
len
(
bytes
)
<
buffer
:
try
:
packet_size_bytes
=
self
.
_sock
.
recv
(
4
)
data
=
self
.
_sock
.
recv
(
buffer
-
len
(
bytes
))
bytes
+=
data
except
socket
.
error
as
err
:
# errno: 35 == Resource temporarily unavailable
if
err
.
errno
!=
35
:
raise
err
return
packet_size_int
=
struct
.
unpack
(
"
>L
"
,
packet_size_bytes
)[
0
]
buffer
=
b
""
while
len
(
buffer
)
<
packet_size_int
:
data
=
self
.
_sock
.
recv
(
packet_size_int
-
len
(
buffer
))
buffer
+=
data
return
buffer
# we didn't get any bytes so return None
elif
bytes
==
b
""
:
return
None
# there is still data remaining so continue trying ot read
return
bytes
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment