From bd7adef79c52895818c6a0dbb1b6de4745bdbcad Mon Sep 17 00:00:00 2001 From: nakhodnov17 <32146790+nakhodnov17@users.noreply.github.com> Date: Sun, 9 Sep 2018 11:24:57 +0300 Subject: [PATCH] Fix port field size (#30) --- include/afina/network/Server.h | 2 +- src/network/blocking/ServerImpl.cpp | 2 +- src/network/blocking/ServerImpl.h | 4 ++-- src/network/nonblocking/ServerImpl.cpp | 2 +- src/network/nonblocking/ServerImpl.h | 4 ++-- src/network/uv/ServerImpl.cpp | 2 +- src/network/uv/ServerImpl.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/afina/network/Server.h b/include/afina/network/Server.h index ea097258a..b04ccece9 100644 --- a/include/afina/network/Server.h +++ b/include/afina/network/Server.h @@ -22,7 +22,7 @@ class Server { * listen on the given interface/port pair to process incomming * data in workers number of threads */ - virtual void Start(uint32_t port, uint16_t workers = 1) = 0; + virtual void Start(uint16_t port, uint16_t workers = 1) = 0; /** * Signal all worker threads that server is going to shutdown. After method returns diff --git a/src/network/blocking/ServerImpl.cpp b/src/network/blocking/ServerImpl.cpp index b448c8eb1..21fbd3c21 100644 --- a/src/network/blocking/ServerImpl.cpp +++ b/src/network/blocking/ServerImpl.cpp @@ -40,7 +40,7 @@ ServerImpl::ServerImpl(std::shared_ptr ps) : Server(ps) {} ServerImpl::~ServerImpl() {} // See Server.h -void ServerImpl::Start(uint32_t port, uint16_t n_workers) { +void ServerImpl::Start(uint16_t port, uint16_t n_workers) { std::cout << "network debug: " << __PRETTY_FUNCTION__ << std::endl; // If a client closes a connection, this will generally produce a SIGPIPE diff --git a/src/network/blocking/ServerImpl.h b/src/network/blocking/ServerImpl.h index 58ab597e3..c6e90f5ff 100644 --- a/src/network/blocking/ServerImpl.h +++ b/src/network/blocking/ServerImpl.h @@ -23,7 +23,7 @@ class ServerImpl : public Server { ~ServerImpl(); // See Server.h - void Start(uint32_t port, uint16_t workers) override; + void Start(uint16_t port, uint16_t workers) override; // See Server.h void Stop() override; @@ -61,7 +61,7 @@ class ServerImpl : public Server { // Port to listen for new connections, permits access only from // inside of accept_thread // Read-only - uint32_t listen_port; + uint16_t listen_port; // Mutex used to access connections list std::mutex connections_mutex; diff --git a/src/network/nonblocking/ServerImpl.cpp b/src/network/nonblocking/ServerImpl.cpp index 74b3a6f68..81ac43134 100644 --- a/src/network/nonblocking/ServerImpl.cpp +++ b/src/network/nonblocking/ServerImpl.cpp @@ -30,7 +30,7 @@ ServerImpl::ServerImpl(std::shared_ptr ps) : Server(ps) {} ServerImpl::~ServerImpl() {} // See Server.h -void ServerImpl::Start(uint32_t port, uint16_t n_workers) { +void ServerImpl::Start(uint16_t port, uint16_t n_workers) { std::cout << "network debug: " << __PRETTY_FUNCTION__ << std::endl; // If a client closes a connection, this will generally produce a SIGPIPE diff --git a/src/network/nonblocking/ServerImpl.h b/src/network/nonblocking/ServerImpl.h index fc48bf9bd..fb61e7718 100644 --- a/src/network/nonblocking/ServerImpl.h +++ b/src/network/nonblocking/ServerImpl.h @@ -22,7 +22,7 @@ class ServerImpl : public Server { ~ServerImpl(); // See Server.h - void Start(uint32_t port, uint16_t workers) override; + void Start(uint16_t port, uint16_t workers) override; // See Server.h void Stop() override; @@ -34,7 +34,7 @@ class ServerImpl : public Server { // Port to listen for new connections, permits access only from // inside of accept_thread // Read-only - uint32_t listen_port; + uint16_t listen_port; // Thread that is accepting new connections std::vector workers; diff --git a/src/network/uv/ServerImpl.cpp b/src/network/uv/ServerImpl.cpp index e382e6353..b22298907 100644 --- a/src/network/uv/ServerImpl.cpp +++ b/src/network/uv/ServerImpl.cpp @@ -18,7 +18,7 @@ ServerImpl::ServerImpl(std::shared_ptr ps) : Server(ps) {} ServerImpl::~ServerImpl() { assert(workers.size() == 0); } // See Server.h -void ServerImpl::Start(uint32_t port, uint16_t n_workers) { +void ServerImpl::Start(uint16_t port, uint16_t n_workers) { struct sockaddr_storage address; int rc = uv_ip4_addr("0.0.0.0", port, (struct sockaddr_in *)&address); if (rc != 0) { diff --git a/src/network/uv/ServerImpl.h b/src/network/uv/ServerImpl.h index 53ea2e054..5fac87231 100644 --- a/src/network/uv/ServerImpl.h +++ b/src/network/uv/ServerImpl.h @@ -23,7 +23,7 @@ class ServerImpl : public Server { ~ServerImpl(); // See Server.h - void Start(uint32_t port, uint16_t workers) override; + void Start(uint16_t port, uint16_t workers) override; // See Server.h void Stop() override;