Skip to content

Commit ab6a634

Browse files
committed
Fix compilation bug with Rust 1.68.2 caused by an unnecessary HRTB (for<'a> ...) that Rust 1.69.0+ are fine with but 1.68.2 is not (perhaps due to rust-lang/rust#103695 which was fixed in Rust 1.69.0).
Also reorder XfrMiddlewareSvc generic types to match the order used in other middleware services, i.e. add the extra type XDP at the end, not before RequestMeta. Also rename Metadata to RequestMeta as in other middleware services. (and fix a comment that is ahead of its time, there is no ZoneMaintainer yet in this branch)
1 parent e70f8ea commit ab6a634

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

src/net/server/middleware/xfr.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const MAX_TCP_MSG_BYTE_LEN: u16 = u16::MAX;
106106
///
107107
/// [module documentation]: crate::net::server::middleware::xfr
108108
#[derive(Clone, Debug)]
109-
pub struct XfrMiddlewareSvc<RequestOctets, NextSvc, XDP, Metadata = ()> {
109+
pub struct XfrMiddlewareSvc<RequestOctets, NextSvc, RequestMeta, XDP> {
110110
/// The upstream [`Service`] to pass requests to and receive responses
111111
/// from.
112112
next_svc: NextSvc,
@@ -123,13 +123,13 @@ pub struct XfrMiddlewareSvc<RequestOctets, NextSvc, XDP, Metadata = ()> {
123123
/// may run concurrently.
124124
batcher_semaphore: Arc<Semaphore>,
125125

126-
_phantom: PhantomData<(RequestOctets, Metadata)>,
126+
_phantom: PhantomData<(RequestOctets, RequestMeta)>,
127127
}
128128

129-
impl<RequestOctets, NextSvc, XDP, Metadata>
130-
XfrMiddlewareSvc<RequestOctets, NextSvc, XDP, Metadata>
129+
impl<RequestOctets, NextSvc, RequestMeta, XDP>
130+
XfrMiddlewareSvc<RequestOctets, NextSvc, RequestMeta, XDP>
131131
where
132-
XDP: XfrDataProvider<Metadata>,
132+
XDP: XfrDataProvider<RequestMeta>,
133133
{
134134
/// Creates a new instance of this middleware.
135135
///
@@ -158,16 +158,16 @@ where
158158
}
159159
}
160160

161-
impl<RequestOctets, NextSvc, XDP, Metadata>
162-
XfrMiddlewareSvc<RequestOctets, NextSvc, XDP, Metadata>
161+
impl<RequestOctets, NextSvc, RequestMeta, XDP>
162+
XfrMiddlewareSvc<RequestOctets, NextSvc, RequestMeta, XDP>
163163
where
164164
RequestOctets: Octets + Send + Sync + 'static + Unpin,
165165
for<'a> <RequestOctets as octseq::Octets>::Range<'a>: Send + Sync,
166166
NextSvc: Service<RequestOctets, ()> + Clone + Send + Sync + 'static,
167167
NextSvc::Future: Send + Sync + Unpin,
168168
NextSvc::Target: Composer + Default + Send + Sync,
169169
NextSvc::Stream: Send + Sync,
170-
XDP: XfrDataProvider<Metadata>,
170+
XDP: XfrDataProvider<RequestMeta>,
171171
XDP::Diff: Debug + 'static,
172172
for<'a> <XDP::Diff as ZoneDiff>::Stream<'a>: Send,
173173
{
@@ -178,7 +178,7 @@ where
178178
pub async fn preprocess(
179179
zone_walking_semaphore: Arc<Semaphore>,
180180
batcher_semaphore: Arc<Semaphore>,
181-
req: &Request<RequestOctets, Metadata>,
181+
req: &Request<RequestOctets, RequestMeta>,
182182
xfr_data_provider: XDP,
183183
) -> Result<
184184
ControlFlow<
@@ -807,19 +807,19 @@ where
807807

808808
//--- impl Service
809809

810-
impl<RequestOctets, NextSvc, XDP, Metadata> Service<RequestOctets, Metadata>
811-
for XfrMiddlewareSvc<RequestOctets, NextSvc, XDP, Metadata>
810+
impl<RequestOctets, NextSvc, RequestMeta, XDP>
811+
Service<RequestOctets, RequestMeta>
812+
for XfrMiddlewareSvc<RequestOctets, NextSvc, RequestMeta, XDP>
812813
where
813814
RequestOctets: Octets + Send + Sync + Unpin + 'static,
814815
for<'a> <RequestOctets as octseq::Octets>::Range<'a>: Send + Sync,
815816
NextSvc: Service<RequestOctets, ()> + Clone + Send + Sync + 'static,
816817
NextSvc::Future: Send + Sync + Unpin,
817818
NextSvc::Target: Composer + Default + Send + Sync,
818819
NextSvc::Stream: Send + Sync,
819-
XDP: XfrDataProvider<Metadata> + Clone + Sync + Send + 'static,
820+
XDP: XfrDataProvider<RequestMeta> + Clone + Sync + Send + 'static,
820821
XDP::Diff: Debug + Sync,
821-
for<'a> <XDP::Diff as ZoneDiff>::Stream<'a>: Send,
822-
Metadata: Clone + Default + Sync + Send + 'static,
822+
RequestMeta: Clone + Default + Sync + Send + 'static,
823823
{
824824
type Target = NextSvc::Target;
825825
type Stream = XfrMiddlewareStream<
@@ -831,7 +831,7 @@ where
831831

832832
fn call(
833833
&self,
834-
request: Request<RequestOctets, Metadata>,
834+
request: Request<RequestOctets, RequestMeta>,
835835
) -> Self::Future {
836836
let request = request.clone();
837837
let next_svc = self.next_svc.clone();
@@ -902,8 +902,8 @@ pub enum XfrDataProviderError {
902902
//------------ Transferable ---------------------------------------------------
903903

904904
/// A provider of data needed for responding to XFR requests.
905-
pub trait XfrDataProvider<Metadata = ()> {
906-
type Diff: ZoneDiff + Send;
905+
pub trait XfrDataProvider<RequestMeta = ()> {
906+
type Diff: ZoneDiff + Send + Sync;
907907

908908
/// Request data needed to respond to an XFR request.
909909
///
@@ -918,7 +918,7 @@ pub trait XfrDataProvider<Metadata = ()> {
918918
#[allow(clippy::type_complexity)]
919919
fn request<Octs>(
920920
&self,
921-
req: &Request<Octs, Metadata>,
921+
req: &Request<Octs, RequestMeta>,
922922
diff_from: Option<Serial>,
923923
) -> Pin<
924924
Box<
@@ -938,16 +938,16 @@ pub trait XfrDataProvider<Metadata = ()> {
938938

939939
//--- impl XfrDataProvider for Deref<XfrDataProvider>
940940

941-
impl<Metadata, T, U> XfrDataProvider<Metadata> for U
941+
impl<RequestMeta, T, U> XfrDataProvider<RequestMeta> for U
942942
where
943-
T: XfrDataProvider<Metadata> + 'static,
943+
T: XfrDataProvider<RequestMeta> + 'static,
944944
U: Deref<Target = T>,
945945
{
946946
type Diff = T::Diff;
947947

948948
fn request<Octs>(
949949
&self,
950-
req: &Request<Octs, Metadata>,
950+
req: &Request<Octs, RequestMeta>,
951951
diff_from: Option<Serial>,
952952
) -> Pin<
953953
Box<
@@ -970,7 +970,7 @@ where
970970

971971
//--- impl XfrDataProvider for Zone
972972

973-
impl<Metadata> XfrDataProvider<Metadata> for Zone {
973+
impl<RequestMeta> XfrDataProvider<RequestMeta> for Zone {
974974
type Diff = EmptyZoneDiff;
975975

976976
/// Request data needed to respond to an XFR request.
@@ -981,7 +981,7 @@ impl<Metadata> XfrDataProvider<Metadata> for Zone {
981981
/// Returns Err if the requested zone is not this zone.
982982
fn request<Octs>(
983983
&self,
984-
req: &Request<Octs, Metadata>,
984+
req: &Request<Octs, RequestMeta>,
985985
_diff_from: Option<Serial>,
986986
) -> Pin<
987987
Box<
@@ -1013,7 +1013,7 @@ impl<Metadata> XfrDataProvider<Metadata> for Zone {
10131013

10141014
//--- impl XfrDataProvider for ZoneTree
10151015

1016-
impl<Metadata> XfrDataProvider<Metadata> for ZoneTree {
1016+
impl<RequestMeta> XfrDataProvider<RequestMeta> for ZoneTree {
10171017
type Diff = EmptyZoneDiff;
10181018

10191019
/// Request data needed to respond to an XFR request.
@@ -1024,7 +1024,7 @@ impl<Metadata> XfrDataProvider<Metadata> for ZoneTree {
10241024
/// Returns Err if the requested zone is not this zone tree.
10251025
fn request<Octs>(
10261026
&self,
1027-
req: &Request<Octs, Metadata>,
1027+
req: &Request<Octs, RequestMeta>,
10281028
_diff_from: Option<Serial>,
10291029
) -> Pin<
10301030
Box<
@@ -2057,7 +2057,7 @@ JAIN-BB.JAIN.AD.JP. IN A 192.41.197.2
20572057
async fn get_zone_soa(zone: &Zone) -> Soa<Name<Bytes>> {
20582058
let read = zone.read();
20592059
let zone_soa_answer =
2060-
XfrMiddlewareSvc::<Vec<u8>, TestNextSvc, Zone>::read_soa(
2060+
XfrMiddlewareSvc::<Vec<u8>, TestNextSvc, (), Zone>::read_soa(
20612061
&read,
20622062
zone.apex_name().to_owned(),
20632063
)
@@ -2176,9 +2176,9 @@ JAIN-BB.JAIN.AD.JP. IN A 192.41.197.2
21762176
)
21772177
}
21782178

2179-
async fn do_preprocess<Metadata, XDP: XfrDataProvider<Metadata>>(
2179+
async fn do_preprocess<RequestMeta, XDP: XfrDataProvider<RequestMeta>>(
21802180
zone: XDP,
2181-
req: &Request<Vec<u8>, Metadata>,
2181+
req: &Request<Vec<u8>, RequestMeta>,
21822182
) -> Result<
21832183
ControlFlow<
21842184
XfrMiddlewareStream<
@@ -2193,7 +2193,7 @@ JAIN-BB.JAIN.AD.JP. IN A 192.41.197.2
21932193
XDP::Diff: Debug + 'static,
21942194
for<'a> <XDP::Diff as ZoneDiff>::Stream<'a>: Send,
21952195
{
2196-
XfrMiddlewareSvc::<Vec<u8>, TestNextSvc, XDP, Metadata>::preprocess(
2196+
XfrMiddlewareSvc::<Vec<u8>, TestNextSvc, RequestMeta, XDP>::preprocess(
21972197
Arc::new(Semaphore::new(1)),
21982198
Arc::new(Semaphore::new(1)),
21992199
req,

src/net/server/tests/integration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ async fn server_tests(#[files("test-data/server/*.rpl")] rpl_file: PathBuf) {
158158
let svc =
159159
EdnsMiddlewareSvc::new(svc).enable(server_config.edns_tcp_keepalive);
160160

161-
// 4. XFR(-in) middleware service (XFR-out is handled by the
162-
// ZoneMaintainer).
163-
let svc = XfrMiddlewareSvc::<Vec<u8>, _, _, Option<Arc<Key>>>::new(
161+
// 4. XFR(-in) middleware service.
162+
let svc = XfrMiddlewareSvc::<Vec<u8>, _, Option<Arc<Key>>, _>::new(
164163
svc, zones, 1,
165164
);
166165

0 commit comments

Comments
 (0)