Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore sndrcv behaviour from before 53afe84 #4538

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

polybassa
Copy link
Contributor

This PR rolls back the internal behaviour of sndrcv from before 53afe84

Two major changes happend in 53afe84

  • inter is only forwarded to time.sleep if it is not 0. However, calling time.sleep(0) gives the python threading system the possibility to do a context switch.
  • before 53afe84 sr was always executed in threaded mode.

@polybassa
Copy link
Contributor Author

Aims to fix #4531

scapy/sendrecv.py Outdated Show resolved Hide resolved
@gpotter2
Copy link
Member

gpotter2 commented Sep 22, 2024

Thanks a lot for figuring this out, this is great work !

@gpotter2 gpotter2 added the bug label Sep 22, 2024
@polybassa
Copy link
Contributor Author

polybassa commented Sep 22, 2024 via email

@@ -323,9 +330,7 @@ def _process_packet(self, r):
self.noans += 1
sentpkt._answered = 1
break
if self._send_done and self.noans >= self.notans and not self.multi:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To explain this code can be reached before the sending thread exists (because of the new time.sleep) in which case the sniffer is never closed

@gpotter2 gpotter2 force-pushed the issue_4531 branch 3 times, most recently from f4e06ce to 9e5d6e6 Compare September 22, 2024 20:52
@gpotter2
Copy link
Member

gpotter2 commented Sep 22, 2024

Seems to really be failing on the UDS_DualDoIPSslSocket6 test :/ If you don't mind I'll let you debug this one.
It seems there are other bugs though, a weird one on MacOS. I'll take a look

# In threaded mode, timeout.
if self.threaded and self.timeout is not None and not self.breakout:
t = time.monotonic() + self.timeout
while time.monotonic() < t:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And while we're at it, this code is disgusting and has terrible perfs. Should have used a lock or something, so I just did that.

@polybassa
Copy link
Contributor Author

Seems to really be failing on the UDS_DualDoIPSslSocket6 test :/ If you don't mind I'll let you debug this one. It seems there are other bugs though, a weird one on MacOS. I'll take a look

Try to get it debug as soon as possible

@polybassa
Copy link
Contributor Author

Could I get #4533 merged before I start debugging?

@gpotter2
Copy link
Member

Sure thing !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants