Skip to content

Commit 554cac7

Browse files
fakeshadowfranz1981
authored andcommitted
[xitca-web]fix io-uring plaintext test. (TechEmpower#8046)
1 parent ad95d53 commit 554cac7

File tree

6 files changed

+74
-98
lines changed

6 files changed

+74
-98
lines changed

frameworks/Rust/xitca-web/Cargo.lock

Lines changed: 55 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/Rust/xitca-web/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ codegen-units = 1
8181
panic = "abort"
8282

8383
[patch.crates-io]
84-
xitca-http = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
85-
xitca-io = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
86-
xitca-postgres = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
87-
xitca-router = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
88-
xitca-server = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
89-
xitca-service = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
90-
xitca-unsafe-collection = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
91-
xitca-web = { git = "https://github.com/HFQR/xitca-web.git", rev = "e648bb2f6e2fd787c2dac0b7e6b0a5bcf7d12f86" }
84+
xitca-http = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
85+
xitca-io = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
86+
xitca-postgres = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
87+
xitca-router = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
88+
xitca-server = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
89+
xitca-service = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
90+
xitca-unsafe-collection = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
91+
xitca-web = { git = "https://github.com/HFQR/xitca-web.git", rev = "c58463d4cd2e58a1fbbe5d15cb4e82c7cd0055bf" }
9292

9393
postgres-protocol = { git = "https://github.com/sfackler/rust-postgres.git", rev = "7cd7b187a5cb990ceb0ea9531cd3345b1e2799c3" }
9494

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "nightly-2023-03-05"
2+
channel = "nightly-2023-03-16"

frameworks/Rust/xitca-web/src/db.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Client {
7878
.next()
7979
.await
8080
.ok_or_else(|| format!("World {id} does not exist"))?
81-
.map(|row| World::new(row.get(0), row.get(1)))
81+
.map(|row| World::new(row.get_raw(0), row.get_raw(1)))
8282
.map_err(Into::into)
8383
}
8484

@@ -137,16 +137,13 @@ impl Client {
137137
pub async fn tell_fortune(&self) -> HandleResult<Fortunes> {
138138
let mut items = Vec::with_capacity(32);
139139

140-
items.push(Fortune::from_static(
141-
0,
142-
"Additional fortune added at request time.",
143-
));
140+
items.push(Fortune::new(0, "Additional fortune added at request time."));
144141

145142
let mut stream = self.client.query_raw::<&[i32]>(&self.fortune, &[]).await?;
146143

147144
while let Some(row) = stream.next().await {
148145
let row = row?;
149-
items.push(Fortune::new(row.get(0), row.get(1)));
146+
items.push(Fortune::new(row.get_raw(0), row.get_raw::<String>(1)));
150147
}
151148

152149
items.sort_by(|it, next| it.message.cmp(&next.message));

frameworks/Rust/xitca-web/src/main_iou.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,20 @@ where
166166
let std = stream.into_std()?;
167167
let stream = tokio_uring::net::TcpStream::from_std(std);
168168

169-
let mut read_buf = BytesMut::new();
169+
let mut read_buf = BytesMut::with_capacity(4096);
170170
let mut write_buf = BytesMut::with_capacity(4096);
171+
let mut paged = PagedBytesMut::new();
171172

172173
let mut ctx = Context::<_, 8>::new(self.date.get());
173174

174175
'io: loop {
175-
read_buf.reserve(4096);
176176
let (res, buf) = stream.read(read_buf).await;
177177
if res? == 0 {
178178
break;
179179
}
180+
read_buf = buf;
181+
paged.get_mut().extend_from_slice(&read_buf);
180182

181-
let mut paged = PagedBytesMut::from(buf);
182183
while let Some((req, _)) = ctx.decode_head::<65535>(&mut paged).unwrap() {
183184
let (parts, body) = self.service.call(req).await.unwrap().into_parts();
184185
let mut encoder = ctx.encode_head(parts, &body, &mut write_buf).unwrap();
@@ -189,7 +190,6 @@ where
189190
}
190191
encoder.encode_eof(&mut write_buf);
191192
}
192-
read_buf = paged.into_inner();
193193

194194
while !write_buf.is_empty() {
195195
let (res, mut w) = stream.write(write_buf).await;

0 commit comments

Comments
 (0)