Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3390cf3

Browse files
authored
Merge pull request#777 from petrosagg/buffered-io
tokio-postgres: buffer sockets to avoid excessive syscalls
2 parents52de269 +ca6d4b8 commit3390cf3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎postgres-native-tls/src/lib.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use std::future::Future;
5151
use std::io;
5252
use std::pin::Pin;
5353
use std::task::{Context,Poll};
54-
use tokio::io::{AsyncRead,AsyncWrite,ReadBuf};
54+
use tokio::io::{AsyncRead,AsyncWrite,BufReader,ReadBuf};
5555
use tokio_postgres::tls;
5656
#[cfg(feature ="runtime")]
5757
use tokio_postgres::tls::MakeTlsConnect;
@@ -115,6 +115,7 @@ where
115115
typeFuture =Pin<Box<dynFuture<Output =Result<TlsStream<S>, native_tls::Error>> +Send>>;
116116

117117
fnconnect(self,stream:S) ->Self::Future{
118+
let stream =BufReader::with_capacity(8192, stream);
118119
let future =asyncmove{
119120
let stream =self.connector.connect(&self.domain, stream).await?;
120121

@@ -126,7 +127,7 @@ where
126127
}
127128

128129
/// The stream returned by `TlsConnector`.
129-
pubstructTlsStream<S>(tokio_native_tls::TlsStream<S>);
130+
pubstructTlsStream<S>(tokio_native_tls::TlsStream<BufReader<S>>);
130131

131132
impl<S>AsyncReadforTlsStream<S>
132133
where

‎postgres-openssl/src/lib.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use std::pin::Pin;
5757
#[cfg(feature ="runtime")]
5858
use std::sync::Arc;
5959
use std::task::{Context,Poll};
60-
use tokio::io::{AsyncRead,AsyncWrite,ReadBuf};
60+
use tokio::io::{AsyncRead,AsyncWrite,BufReader,ReadBuf};
6161
use tokio_openssl::SslStream;
6262
use tokio_postgres::tls;
6363
#[cfg(feature ="runtime")]
@@ -140,6 +140,7 @@ where
140140
typeFuture =Pin<Box<dynFuture<Output =Result<TlsStream<S>,Self::Error>> +Send>>;
141141

142142
fnconnect(self,stream:S) ->Self::Future{
143+
let stream =BufReader::with_capacity(8192, stream);
143144
let future =asyncmove{
144145
let ssl =self.ssl.into_ssl(&self.domain)?;
145146
letmut stream =SslStream::new(ssl, stream)?;
@@ -182,7 +183,7 @@ impl Error for ConnectError {
182183
}
183184

184185
/// The stream returned by `TlsConnector`.
185-
pubstructTlsStream<S>(SslStream<S>);
186+
pubstructTlsStream<S>(SslStream<BufReader<S>>);
186187

187188
impl<S>AsyncReadforTlsStream<S>
188189
where

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp