Skip to content

Commit

Permalink
server-common patch: put a clone of Info into Conn StateSet
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Oct 18, 2023
1 parent c56dbf2 commit 732a128
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ where
observer: self.observer.clone(),
register_signals: self.register_signals,
max_connections: self.max_connections,
info: AsyncCell::shared(),
info: Arc::clone(&self.info),
completion_future: CompletionFuture::new(),
binding: RwLock::new(None),
}
Expand Down
4 changes: 3 additions & 1 deletion server-common/src/config_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{Acceptor, CloneCounterObserver, Config, Server, Stopper, Transport};

use futures_lite::prelude::*;
use std::{
convert::{TryFrom, TryInto},
Expand Down Expand Up @@ -170,6 +169,9 @@ where
let handler = &handler;
let result = HttpConn::map(stream, self.stopper.clone(), |mut conn| async {
conn.set_peer_ip(peer_ip);
if let Some(info) = self.info.try_get() {
conn.state_mut().insert(info);
}
let conn = handler.run(conn.into()).await;
let conn = handler.before_send(conn).await;

Expand Down

0 comments on commit 732a128

Please sign in to comment.