Skip to content

Clean asynchronous stop_callback implementation #1523

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

Closed
wants to merge 1 commit into from

Conversation

gpotter2
Copy link
Member

This PR:

image

I will add the unit tests if we agree on the PR

@@ -897,7 +903,7 @@ def _select(sockets):
read_allowed_exceptions = (PcapTimeoutElapsed,)

def _select(sockets):
return sockets
return select_objects(sockets, remain=0)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to self: separate

  • WINDOWS and started_callback ==> use select_objects
  • WINDOWS and not started_callback ==> previous behavior: dont use select_objects

@guedou
Copy link
Member

guedou commented Jan 14, 2019

@gpotter2 what is the status of this PR?

@gpotter2
Copy link
Member Author

gpotter2 commented Jan 18, 2019

Quite unknown :/ I’m still not sure wether this was a good idea at all

I’ll run some benchmarks and try to make it work with the recent select overhaul, to see what it becomes :/

@voi98306
Copy link

voi98306 commented May 4, 2019

This is a VERY useful feature, implemented in a way consistent with how it has been done in C since at least the mid 90's, and thus well battle proven. I would REALLY like to see this coming out in a release.

The only comment I have is that if you return something more resembling an object, rather than a mere stop_... function, you can easily in the future add additional reasons for communicating with the sniff function without breaking backwards compatibility.

So instead of sending the "stop_callback" function to "started_callback", send a communication structure allowing the user to call "commstruct.stop_sniffing()". That way, in the future you can add other methods, like "commstruct.extend_timeout()" or whatever. Other changes needed to accomodate new features (such as not merely clearing the select list when objpipe is written to) will be well hidden behind the interface.

I am a huge fan and really appreciate your work. I hope to see this feature in a not too distant release.

@gpotter2
Copy link
Member Author

gpotter2 commented May 4, 2019

The only comment I have is that if you return something more resembling an object, rather than a mere stop_... function, you can easily in the future add additional reasons for communicating with the sniff function without breaking backwards compatibility.

Good point. I think the best option would be to implement a sniff_async function (or a threaded argument to sniff) that would pop a sniff in a thread and return such an object.

@gpotter2
Copy link
Member Author

@voi98306 It's not ready yet (some tests still fail), but there's a working demo over #1999

@gpotter2 gpotter2 closed this May 26, 2019
@gpotter2 gpotter2 deleted the stop-callback branch June 1, 2019 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide stop for sniff even when no packets received
3 participants