Skip to content

Commit 8a3e819

Browse files
authored
SharedCfg is not Copy (#766)
1 parent 577cc1e commit 8a3e819

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+446
-289
lines changed

.github/workflows/miri.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ jobs:
2828
- name: Cache Dependencies
2929
uses: Swatinem/rust-cache@v2.8.2
3030

31-
- name: Run Miri
31+
- name: Run Miri (bytes)
3232
# Run all of your tests inside of Miri interpreter
3333
run: cargo miri test -p ntex-bytes
34+
35+
- name: Run Miri (ntex-service::cfg)
36+
# Run all of your tests inside of Miri interpreter
37+
run: cargo miri test -p ntex-service -- --test "cfg::tests::"
38+
39+
- name: Run Miri (ntex-io)
40+
# Run all of your tests inside of Miri interpreter
41+
run: cargo miri test -p ntex-io -- --test "miri_"

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ edition = "2024"
2626
rust-version = "1.88"
2727

2828
[workspace.lints.rust]
29-
async_fn_in_trait = { level = "allow", priority = -1 }
29+
async_fn_in_trait = { level = "allow", priority = -1 }
3030
rust_2018_idioms = "deny"
3131
warnings = "deny"
3232
unreachable_pub = "deny"
@@ -54,18 +54,18 @@ ntex-util = { path = "ntex-util" }
5454
ntex = "3.3.0"
5555
ntex-bytes = "1.5.0"
5656
ntex-codec = "1.1.0"
57-
ntex-io = "3.7.1"
57+
ntex-io = "3.9.0"
5858
ntex-dispatcher = "3.1.0"
59-
ntex-net = "3.6.3"
59+
ntex-net = "3.7.0"
6060
ntex-http = "1.0.0"
6161
ntex-router = "1.0.0"
6262
ntex-rt = "3.7.0"
63-
ntex-server = "3.7.0"
64-
ntex-service = "4.4.0"
65-
ntex-tls = "3.2.1"
63+
ntex-server = "3.8.0"
64+
ntex-service = "4.5.0"
65+
ntex-tls = "3.3.0"
6666
ntex-macros = "3.1.0"
6767
ntex-util = "3.4.0"
68-
ntex-h2 = "3.6.2"
68+
ntex-h2 = "3.7.1"
6969

7070
ntex-polling = "3.10.0"
7171
ntex-io-uring = "0.7.120"

ntex-io/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## [3.9.0] - 2026-02-16
4+
5+
* SharedCfg is not Copy
6+
37
## [3.8.0] - 2026-02-03
48

59
* Refactor Io filter management

ntex-io/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ntex-io"
3-
version = "3.8.0"
3+
version = "3.9.0"
44
authors = ["ntex contributors <team@ntex.rs>"]
55
description = "Utilities for abstracting io streams"
66
keywords = ["network", "framework", "async", "futures"]

ntex-io/src/cfg.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ thread_local! {
1313
static CACHE: LocalCache = LocalCache::new();
1414
}
1515

16-
#[derive(Clone, Debug)]
16+
#[derive(Debug)]
1717
/// Base io configuration
1818
pub struct IoConfig {
1919
connect_timeout: Millis,
@@ -43,9 +43,9 @@ impl Configuration for IoConfig {
4343
}
4444

4545
fn set_ctx(&mut self, ctx: CfgContext) {
46-
self.config = ctx;
4746
self.read_buf.idx = ctx.id();
4847
self.write_buf.idx = ctx.id();
48+
self.config = ctx;
4949
}
5050
}
5151

@@ -72,6 +72,7 @@ impl IoConfig {
7272
/// Create new config object
7373
pub fn new() -> IoConfig {
7474
let config = CfgContext::default();
75+
let idx = config.id();
7576

7677
IoConfig {
7778
config,
@@ -81,18 +82,18 @@ impl IoConfig {
8182
frame_read_rate: None,
8283

8384
read_buf: BufConfig {
85+
idx,
8486
high: DEFAULT_HIGH,
8587
low: DEFAULT_LOW,
8688
half: DEFAULT_HALF,
87-
idx: config.id(),
8889
first: true,
8990
cache_size: DEFAULT_CACHE_SIZE,
9091
},
9192
write_buf: BufConfig {
93+
idx,
9294
high: DEFAULT_HIGH,
9395
low: DEFAULT_LOW,
9496
half: DEFAULT_HALF,
95-
idx: config.id(),
9697
first: false,
9798
cache_size: DEFAULT_CACHE_SIZE,
9899
},

ntex-io/src/filterptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ mod tests {
209209
}
210210

211211
#[test]
212-
fn take_sealed_filter() {
212+
fn miri_sealed_filter() {
213213
let p = Rc::new(Cell::new(0));
214214
let f = DropFilter { p: p.clone() };
215215

@@ -219,7 +219,7 @@ mod tests {
219219

220220
#[test]
221221
#[should_panic(expected = "Filter is not set")]
222-
fn take_filter_access() {
222+
fn miri_filter_access() {
223223
let fptr = FilterPtr::null();
224224
fptr.filter::<Base>();
225225
}

ntex-io/src/io.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::task::{Context, Poll};
44
use std::{fmt, hash, io, marker, mem, ops, pin::Pin, ptr, rc::Rc};
55

66
use ntex_codec::{Decoder, Encoder};
7-
use ntex_service::cfg::SharedCfg;
7+
use ntex_service::cfg::{Cfg, SharedCfg};
88
use ntex_util::{future::Either, task::LocalWaker};
99

1010
use crate::buf::Stack;
@@ -24,7 +24,7 @@ pub struct IoRef(pub(super) Rc<IoState>);
2424

2525
pub(crate) struct IoState {
2626
filter: FilterPtr,
27-
pub(super) cfg: Cell<&'static IoConfig>,
27+
pub(super) cfg: Cfg<IoConfig>,
2828
pub(super) flags: Cell<Flags>,
2929
pub(super) error: Cell<Option<io::Error>>,
3030
pub(super) read_task: LocalWaker,
@@ -65,7 +65,7 @@ impl IoState {
6565
flags.insert(Flags::DSP_TIMEOUT);
6666
self.flags.set(flags);
6767
self.dispatch_task.wake();
68-
log::trace!("{}: Timer, notify dispatcher", self.cfg.get().tag());
68+
log::trace!("{}: Timer, notify dispatcher", self.cfg.tag());
6969
}
7070
}
7171

@@ -98,7 +98,7 @@ impl IoState {
9898
if !self.flags.get().is_stopped() {
9999
log::trace!(
100100
"{}: {:?} Io error {:?} flags: {:?}",
101-
self.cfg.get().tag(),
101+
self.cfg.tag(),
102102
ptr::from_ref(self),
103103
err,
104104
self.flags.get()
@@ -120,7 +120,7 @@ impl IoState {
120120
if !self.dispatch_task.wake_checked() {
121121
log::trace!(
122122
"{}: {:?} Dispatcher is not registered, flags: {:?}",
123-
self.cfg.get().tag(),
123+
self.cfg.tag(),
124124
ptr::from_ref(self),
125125
self.flags.get()
126126
);
@@ -137,7 +137,7 @@ impl IoState {
137137
{
138138
log::trace!(
139139
"{}: Initiate io shutdown {:?}",
140-
self.cfg.get().tag(),
140+
self.cfg.tag(),
141141
self.flags.get()
142142
);
143143
self.insert_flags(Flags::IO_STOPPING_FILTERS);
@@ -147,12 +147,12 @@ impl IoState {
147147

148148
#[inline]
149149
pub(super) fn read_buf(&self) -> &BufConfig {
150-
self.cfg.get().read_buf()
150+
self.cfg.read_buf()
151151
}
152152

153153
#[inline]
154154
pub(super) fn write_buf(&self) -> &BufConfig {
155-
self.cfg.get().write_buf()
155+
self.cfg.write_buf()
156156
}
157157
}
158158

@@ -194,7 +194,7 @@ impl Io {
194194
/// Create `Io` instance
195195
pub fn new<I: IoStream, T: Into<SharedCfg>>(io: I, cfg: T) -> Self {
196196
let inner = Rc::new(IoState {
197-
cfg: Cell::new(cfg.into().get::<IoConfig>().into_static()),
197+
cfg: cfg.into().get::<IoConfig>(),
198198
filter: FilterPtr::null(),
199199
flags: Cell::new(Flags::WR_PAUSED),
200200
error: Cell::new(None),
@@ -237,7 +237,7 @@ impl<F> Io<F> {
237237

238238
fn take_io_ref(&self) -> IoRef {
239239
let inner = Rc::new(IoState {
240-
cfg: Cell::new(SharedCfg::default().get::<IoConfig>().into_static()),
240+
cfg: SharedCfg::default().get::<IoConfig>(),
241241
filter: FilterPtr::null(),
242242
flags: Cell::new(
243243
Flags::IO_STOPPED | Flags::IO_STOPPING | Flags::IO_STOPPING_FILTERS,
@@ -278,9 +278,9 @@ impl<F> Io<F> {
278278
#[inline]
279279
/// Set shared io config
280280
pub fn set_config<T: Into<SharedCfg>>(&self, cfg: T) {
281-
self.st()
282-
.cfg
283-
.set(cfg.into().get::<IoConfig>().into_static());
281+
unsafe {
282+
self.st().cfg.replace(cfg.into().get::<IoConfig>());
283+
}
284284
}
285285
}
286286

@@ -708,7 +708,7 @@ impl<F> Drop for Io<F> {
708708
if !st.flags.get().is_stopped() {
709709
log::trace!(
710710
"{}: Io is dropped, force stopping io streams {:?}",
711-
st.cfg.get().tag(),
711+
st.cfg.tag(),
712712
st.flags.get()
713713
);
714714
}

ntex-io/src/ioref.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl IoRef {
1414
#[inline]
1515
/// Get tag
1616
pub fn tag(&self) -> &'static str {
17-
self.0.cfg.get().tag()
17+
self.0.cfg.tag()
1818
}
1919

2020
#[inline]
@@ -32,14 +32,14 @@ impl IoRef {
3232

3333
#[inline]
3434
/// Get configuration
35-
pub fn cfg(&self) -> &'static IoConfig {
36-
self.0.cfg.get()
35+
pub fn cfg(&self) -> &IoConfig {
36+
&self.0.cfg
3737
}
3838

3939
#[inline]
4040
/// Get shared configuration
4141
pub fn shared(&self) -> SharedCfg {
42-
self.0.cfg.get().config.shared()
42+
self.0.cfg.shared()
4343
}
4444

4545
#[inline]

ntex-net/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## [3.7.0] - 2026-02-16
4+
5+
* SharedCfg is not Copy
6+
37
## [3.6.3] - 2026-02-12
48

59
* Fix compio io shutdown

ntex-net/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ntex-net"
3-
version = "3.6.3"
3+
version = "3.7.0"
44
authors = ["ntex contributors <team@ntex.rs>"]
55
description = "ntexwork utils for ntex framework"
66
keywords = ["network", "framework", "async", "futures"]

0 commit comments

Comments
 (0)