Skip to content

Commit

Permalink
Fix segfault in ServerSettings::get_response_builder()
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed May 12, 2018
1 parent 75861a2 commit ed9971b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cache:

matrix:
include:
- rust: 1.21.0
- rust: stable
- rust: beta
- rust: nightly
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-web"
version = "0.5.7"
version = "0.5.8"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
readme = "README.md"
Expand Down
19 changes: 15 additions & 4 deletions src/server/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<net::SocketAddr>,
secure: bool,
Expand All @@ -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<Option<CpuPool>>,
}
Expand Down Expand Up @@ -72,7 +83,7 @@ impl Default for ServerSettings {
impl ServerSettings {
/// Crate server settings instance
pub(crate) fn new(
addr: Option<net::SocketAddr>, host: &Option<String>, secure: bool
addr: Option<net::SocketAddr>, host: &Option<String>, secure: bool,
) -> ServerSettings {
let host = if let Some(ref host) = *host {
host.clone()
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit ed9971b

Please sign in to comment.