From ed9971b2128ec7a8b1455fc67123613cc38420d6 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 11 May 2018 21:43:13 -0700 Subject: [PATCH] Fix segfault in ServerSettings::get_response_builder() --- .travis.yml | 1 - CHANGES.md | 5 +++++ Cargo.toml | 2 +- src/server/settings.rs | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a69ce1881..fcbddda00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ cache: matrix: include: - - rust: 1.21.0 - rust: stable - rust: beta - rust: nightly diff --git a/CHANGES.md b/CHANGES.md index 6c3307401..9c11cb609 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changes +## 0.5.8 (2018-05-11) + +* Fix segfault in ServerSettings::get_response_builder() + + ## 0.5.7 (2018-05-09) * Fix http/2 payload streaming #215 diff --git a/Cargo.toml b/Cargo.toml index a04dabeb5..3dbe13a02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.5.7" +version = "0.5.8" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/src/server/settings.rs b/src/server/settings.rs index 1b57db1a2..f75033c1b 100644 --- a/src/server/settings.rs +++ b/src/server/settings.rs @@ -8,15 +8,14 @@ use std::sync::Arc; use std::{fmt, mem, net}; use time; -use super::KeepAlive; use super::channel::Node; use super::helpers; use super::shared::{SharedBytes, SharedBytesPool}; +use super::KeepAlive; use body::Body; use httpresponse::{HttpResponse, HttpResponseBuilder, HttpResponsePool}; /// Various server settings -#[derive(Clone)] pub struct ServerSettings { addr: Option, secure: bool, @@ -28,6 +27,18 @@ pub struct ServerSettings { unsafe impl Sync for ServerSettings {} unsafe impl Send for ServerSettings {} +impl Clone for ServerSettings { + fn clone(&self) -> Self { + ServerSettings { + addr: self.addr, + secure: self.secure, + host: self.host.clone(), + cpu_pool: self.cpu_pool.clone(), + responses: HttpResponsePool::pool(), + } + } +} + struct InnerCpuPool { cpu_pool: UnsafeCell>, } @@ -72,7 +83,7 @@ impl Default for ServerSettings { impl ServerSettings { /// Crate server settings instance pub(crate) fn new( - addr: Option, host: &Option, secure: bool + addr: Option, host: &Option, secure: bool, ) -> ServerSettings { let host = if let Some(ref host) = *host { host.clone() @@ -119,7 +130,7 @@ impl ServerSettings { #[inline] pub(crate) fn get_response_builder( - &self, status: StatusCode + &self, status: StatusCode, ) -> HttpResponseBuilder { HttpResponsePool::get_builder(&self.responses, status) }