Skip to content

Depending directly on blocking (which smol exports) rather than pulli… #29

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Cargo.lock
.idea
target
*.a
.vscode
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ repository = "https://github.com/dbcfd/pcap-async"
exclude = ["resources/*.pcap"]

[dependencies]
blocking = "1.0.0"
byteorder = "1.3"
futures = "0.3"
libc = "0.2"
log = "0.4"
mio = "0.6"
pin-project = "0.4"
pcap-sys = "0.1"
smol = "1.2"
thiserror = "1.0"

[dev-dependencies]
Expand Down
12 changes: 7 additions & 5 deletions src/bridge_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ mod tests {
let packet_provider = BridgeStream::new(vec![packet_stream], Duration::from_millis(100), 2)
.expect("Failed to build");

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let fut_packets = packet_provider.collect::<Vec<_>>();
let packets: Vec<_> = fut_packets
.await
Expand Down Expand Up @@ -382,7 +382,7 @@ mod tests {
let packet_provider = BridgeStream::new(vec![packet_stream], Duration::from_millis(100), 2)
.expect("Failed to build");

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let fut_packets = async move {
let mut packet_provider = packet_provider.boxed();
let mut packets = vec![];
Expand Down Expand Up @@ -419,7 +419,8 @@ mod tests {

assert!(
stream.is_ok(),
format!("Could not build stream {}", stream.err().unwrap())
"Could not build stream {}",
stream.err().unwrap()
);
}

Expand All @@ -440,7 +441,8 @@ mod tests {

assert!(
stream.is_ok(),
format!("Could not build stream {}", stream.err().unwrap())
"Could not build stream {}",
stream.err().unwrap()
);
}

Expand Down Expand Up @@ -469,7 +471,7 @@ mod tests {
let stream1 = futures::stream::iter(vec![item1]);
let stream2 = futures::stream::iter(vec![item2]);

let result = smol::block_on(async move {
let result = futures::executor::block_on(async move {
let bridge = BridgeStream::new(vec![stream1, stream2], Duration::from_millis(100), 0);

let result = bridge
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mod tests {
let mut cfg = Config::default();
cfg.with_max_packets_read(5000);

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let packet_provider =
PacketStream::new(Config::default(), std::sync::Arc::clone(&handle))
.expect("Failed to build");
Expand Down
2 changes: 1 addition & 1 deletion src/packet/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl DispatchArgs {
async fn poll(&self, timeout: Option<Duration>) -> Result<InterfaceReady, Error> {
trace!("Polling FD with timeout {:?}", timeout);
let fd = self.fd.clone();
smol::unblock(move || poll_ready(fd, timeout)).await
blocking::unblock(move || poll_ready(fd, timeout)).await
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mod tests {
let handle = Handle::file_capture(pcap_path.to_str().expect("No path found"))
.expect("No handle created");

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let packet_provider =
PacketStream::new(Config::default(), Arc::clone(&handle)).expect("Failed to build");
let fut_packets = packet_provider.collect::<Vec<_>>();
Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
let handle = Handle::file_capture(pcap_path.to_str().expect("No path found"))
.expect("No handle created");

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let packet_provider =
PacketStream::new(Config::default(), Arc::clone(&handle)).expect("Failed to build");
let fut_packets = packet_provider.collect::<Vec<_>>();
Expand Down Expand Up @@ -200,7 +200,7 @@ mod tests {

info!("Testing against {:?}", pcap_path);

let packets = smol::block_on(async move {
let packets = futures::executor::block_on(async move {
let handle = Handle::file_capture(pcap_path.to_str().expect("No path found"))
.expect("No handle created");

Expand Down Expand Up @@ -239,12 +239,13 @@ mod tests {

assert!(
stream.is_ok(),
format!("Could not build stream {}", stream.err().unwrap())
"Could not build stream {}",
stream.err().unwrap()
);

let mut stream = stream.unwrap();

smol::block_on(async move { stream.next().await })
futures::executor::block_on(async move { stream.next().await })
.unwrap()
.unwrap();
}
Expand All @@ -264,7 +265,8 @@ mod tests {

assert!(
stream.is_ok(),
format!("Could not build stream {}", stream.err().unwrap())
"Could not build stream {}",
stream.err().unwrap()
);
}
}