From 522c9a5ea6eb45c1350a20b4d34d62908f736a78 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 31 Dec 2020 03:24:18 +0000 Subject: [PATCH 1/3] update CoC text --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62ee50243..956bb3741 100644 --- a/README.md +++ b/README.md @@ -107,5 +107,5 @@ at your option. ## Code of Conduct -Contribution to the actix-web crate is organized under the terms of the Contributor Covenant, the -maintainers of Actix web, promises to intervene to uphold that code of conduct. +Contribution to the actix-web repo is organized under the terms of the Contributor Covenant. +The Actix team promises to intervene to uphold that code of conduct. From 3beb4cf2da01440c2b6454558dba70274305dd18 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Sat, 2 Jan 2021 07:18:25 +0800 Subject: [PATCH 2/3] replace tinyvec with smallvec (#1866) --- Cargo.toml | 2 +- src/app_service.rs | 2 -- src/request.rs | 18 ++++++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6ed327f56..e33ff844b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ time = { version = "0.2.7", default-features = false, features = ["std"] } url = "2.1" open-ssl = { package = "openssl", version = "0.10", optional = true } rust-tls = { package = "rustls", version = "0.18.0", optional = true } -tinyvec = { version = "1", features = ["alloc"] } +smallvec = "1.6" [dev-dependencies] actix = "0.10.0" diff --git a/src/app_service.rs b/src/app_service.rs index e5f8dd9cf..4452778df 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -10,7 +10,6 @@ use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url}; use actix_service::boxed::{self, BoxService, BoxServiceFactory}; use actix_service::{fn_service, Service, ServiceFactory}; use futures_util::future::{join_all, ok, FutureExt, LocalBoxFuture}; -use tinyvec::tiny_vec; use crate::config::{AppConfig, AppService}; use crate::data::{DataFactory, FnDataFactory}; @@ -246,7 +245,6 @@ where inner.path.reset(); inner.head = head; inner.payload = payload; - inner.app_data = tiny_vec![self.data.clone()]; req } else { HttpRequest::new( diff --git a/src/request.rs b/src/request.rs index bd4bbbf58..432134cd7 100644 --- a/src/request.rs +++ b/src/request.rs @@ -6,7 +6,7 @@ use actix_http::http::{HeaderMap, Method, Uri, Version}; use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead}; use actix_router::{Path, Url}; use futures_util::future::{ok, Ready}; -use tinyvec::TinyVec; +use smallvec::SmallVec; use crate::config::AppConfig; use crate::error::UrlGenerationError; @@ -22,7 +22,7 @@ pub(crate) struct HttpRequestInner { pub(crate) head: Message, pub(crate) path: Path, pub(crate) payload: Payload, - pub(crate) app_data: TinyVec<[Rc; 4]>, + pub(crate) app_data: SmallVec<[Rc; 4]>, rmap: Rc, config: AppConfig, pool: &'static HttpRequestPool, @@ -39,7 +39,7 @@ impl HttpRequest { app_data: Rc, pool: &'static HttpRequestPool, ) -> HttpRequest { - let mut data = TinyVec::<[Rc; 4]>::new(); + let mut data = SmallVec::<[Rc; 4]>::new(); data.push(app_data); HttpRequest(Rc::new(HttpRequestInner { @@ -277,10 +277,16 @@ impl HttpMessage for HttpRequest { impl Drop for HttpRequest { fn drop(&mut self) { // if possible, contribute to current worker's HttpRequest allocation pool - if Rc::strong_count(&self.0) == 1 { - let v = &mut self.0.pool.0.borrow_mut(); + + // This relies on no Weak exists anywhere.(There is none) + if let Some(inner) = Rc::get_mut(&mut self.0) { + let v = &mut inner.pool.0.borrow_mut(); if v.len() < 128 { - self.extensions_mut().clear(); + // clear additional app_data and keep the root one for reuse. + inner.app_data.truncate(1); + // inner is borrowed mut here. get head's Extension mutably + // to reduce borrow check + inner.head.extensions.get_mut().clear(); v.push(self.0.clone()); } } From a1b00b2cd07362fa2e219c3256d4c0ca2eabb6b4 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 2 Jan 2021 00:12:18 +0000 Subject: [PATCH 3/3] change unreleased year --- CHANGES.md | 3 ++- actix-files/CHANGES.md | 2 +- actix-http-test/CHANGES.md | 2 +- actix-http/CHANGES.md | 3 ++- actix-multipart/CHANGES.md | 2 +- actix-web-actors/CHANGES.md | 3 ++- actix-web-codegen/CHANGES.md | 2 +- awc/CHANGES.md | 2 +- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fa56acc17..2e886e0f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx ### Changed * Bumped `rand` to `0.8` * Rename `Handler` to `HandlerService` and rename `Factory` to `Handler`. [#1852] @@ -12,6 +12,7 @@ [#1812]: https://github.com/actix/actix-web/pull/1812 [#1852]: https://github.com/actix/actix-web/pull/1852 + ## 3.3.2 - 2020-12-01 ### Fixed * Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. [#1762] diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 49768419b..f992e5fdb 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx * `HttpRange::parse` now has its own error type. diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index 835b75ddc..535766373 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx ## 2.1.0 - 2020-11-25 diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index c43246bb0..1d0cc3d31 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,9 +1,10 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx ### Changed * Bumped `rand` to `0.8` + ### Removed * Deprecated `on_connect` methods have been removed. Prefer the new `on_connect_ext` technique. [#1857] diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 446ca5ad2..0d13d5015 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx * Fix multipart consuming payload before header checks #1513 diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 9df0df159..0d830fe64 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -1,8 +1,9 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx * Upgrade `pin-project` to `1.0`. + ## 3.0.0 - 2020-09-11 * No significant changes from `3.0.0-beta.2`. diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 1ab51f924..a7675d9dd 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx ## 0.4.0 - 2020-09-20 diff --git a/awc/CHANGES.md b/awc/CHANGES.md index e4f801bbe..ee795fccb 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## Unreleased - 2020-xx-xx +## Unreleased - 2021-xx-xx ### Changed * Bumped `rand` to `0.8`