Commit 71416e36 authored by neverlord's avatar neverlord

renamed native_socket_t to native_socket_type

parent 3aa024f6
......@@ -154,7 +154,7 @@ class buffer
return append_impl(fun, throw_on_error);
}
bool append_from(native_socket_t sfd, int rdflags,
bool append_from(native_socket_type sfd, int rdflags,
bool throw_on_error = false)
{
auto _this = this;
......
......@@ -25,9 +25,9 @@ struct mailman_send_job
struct mailman_add_peer
{
native_socket_t sockfd;
native_socket_type sockfd;
process_information_ptr pinfo;
inline mailman_add_peer(native_socket_t fd,
inline mailman_add_peer(native_socket_type fd,
const process_information_ptr& piptr)
: sockfd(fd), pinfo(piptr)
{
......@@ -53,7 +53,7 @@ class mailman_job
const channel_ptr& to,
const any_tuple& omsg);
mailman_job(native_socket_t sockfd, const process_information_ptr& pinfo);
mailman_job(native_socket_type sockfd, const process_information_ptr& pinfo);
static mailman_job* kill_job();
......
......@@ -15,14 +15,16 @@
namespace cppa { namespace detail {
#ifdef CPPA_WINDOWS
typedef SOCKET native_socket_t;
typedef SOCKET native_socket_type;
typedef const char* socket_send_ptr;
typedef char* socket_recv_ptr;
constexpr SOCKET invalid_socket = INVALID_SOCKET;
#else
typedef int native_socket_t;
typedef int native_socket_type;
typedef const void* socket_send_ptr;
typedef void* socket_recv_ptr;
void closesocket(native_socket_t s);
constexpr int invalid_socket = -1;
void closesocket(native_socket_type s);
#endif
} } // namespace cppa::detail
......
......@@ -10,17 +10,17 @@ namespace cppa { namespace detail {
void post_office_loop(int pipe_read_handle, int pipe_write_handle);
void post_office_add_peer(native_socket_t peer_socket,
void post_office_add_peer(native_socket_type peer_socket,
const process_information_ptr& peer_ptr,
const actor_proxy_ptr& peer_actor_ptr,
std::unique_ptr<attachable>&& peer_observer);
void post_office_publish(native_socket_t server_socket,
void post_office_publish(native_socket_type server_socket,
const actor_ptr& published_actor);
void post_office_unpublish(actor_id whom);
void post_office_close_socket(native_socket_t sfd);
void post_office_close_socket(native_socket_type sfd);
} } // namespace cppa::detail
......
......@@ -27,12 +27,12 @@ class post_office_msg
struct add_peer
{
native_socket_t sockfd;
native_socket_type sockfd;
process_information_ptr peer;
actor_proxy_ptr first_peer_actor;
std::unique_ptr<attachable> attachable_ptr;
add_peer(native_socket_t peer_socket,
add_peer(native_socket_type peer_socket,
const process_information_ptr& peer_ptr,
const actor_proxy_ptr& peer_actor_ptr,
std::unique_ptr<attachable>&& peer_observer);
......@@ -42,10 +42,10 @@ class post_office_msg
struct add_server_socket
{
native_socket_t server_sockfd;
native_socket_type server_sockfd;
actor_ptr published_actor;
add_server_socket(native_socket_t ssockfd, const actor_ptr& whom);
add_server_socket(native_socket_type ssockfd, const actor_ptr& whom);
};
......@@ -55,12 +55,12 @@ class post_office_msg
inline proxy_exited(const actor_proxy_ptr& who) : proxy_ptr(who) { }
};
post_office_msg(native_socket_t arg0,
post_office_msg(native_socket_type arg0,
const process_information_ptr& arg1,
const actor_proxy_ptr& arg2,
std::unique_ptr<attachable>&& arg3);
post_office_msg(native_socket_t arg0, const actor_ptr& arg1);
post_office_msg(native_socket_type arg0, const actor_ptr& arg1);
post_office_msg(const actor_proxy_ptr& proxy_ptr);
......
......@@ -21,7 +21,7 @@ mailman_job::mailman_job(process_information_ptr piptr,
new (&m_send_job) mailman_send_job (piptr, from, to, content);
}
mailman_job::mailman_job(native_socket_t sockfd, const process_information_ptr& pinfo)
mailman_job::mailman_job(native_socket_type sockfd, const process_information_ptr& pinfo)
: next(0), m_type(add_peer_type)
{
new (&m_add_socket) mailman_add_peer (sockfd, pinfo);
......@@ -69,7 +69,7 @@ void mailman_loop()
// caches mailman_queue()
auto& mqueue = mailman_queue();
// connected tcp peers
std::map<process_information, native_socket_t> peers;
std::map<process_information, native_socket_type> peers;
for (;;)
{
job = mqueue.pop();
......
......@@ -9,7 +9,7 @@ namespace cppa { namespace detail {
#ifndef CPPA_WINDOWS
void closesocket(native_socket_t s)
void closesocket(native_socket_type s)
{
if(::close(s) != 0)
{
......
......@@ -61,7 +61,7 @@ constexpr size_t s_max_buffer_size = (1024 * 1024);
static_assert((s_max_buffer_size % s_chunk_size) == 0,
"max_buffer_size is not a multiple of chunk_size");
static_assert(sizeof(cppa::detail::native_socket_t) == sizeof(std::uint32_t),
static_assert(sizeof(cppa::detail::native_socket_type) == sizeof(std::uint32_t),
"sizeof(native_socket_t) != sizeof(std::uint32_t)");
constexpr int s_rdflag = MSG_DONTWAIT;
......@@ -93,9 +93,9 @@ class po_peer
state m_state;
// TCP socket to remote peer
native_socket_t m_socket;
native_socket_type m_socket;
// TCP socket identifying our parent (that accepted m_socket)
native_socket_t m_parent_socket;
native_socket_type m_parent_socket;
// caches process_information::get()
process_information_ptr m_pself;
// the process information or our remote peer
......@@ -119,7 +119,7 @@ class po_peer
{
}
explicit po_peer(native_socket_t sockfd, native_socket_t parent_socket)
explicit po_peer(native_socket_type sockfd, native_socket_type parent_socket)
: m_state(wait_for_process_info)
, m_socket(sockfd)
, m_parent_socket(parent_socket)
......@@ -146,7 +146,7 @@ class po_peer
// other.m_children.clear();
}
native_socket_t get_socket() const
native_socket_type get_socket() const
{
return m_socket;
}
......@@ -344,7 +344,7 @@ class po_doorman
{
// server socket
native_socket_t m_socket;
native_socket_type m_socket;
actor_ptr published_actor;
std::list<po_peer>* m_peers;
// caches process_information::get()
......@@ -375,7 +375,7 @@ class po_doorman
other.m_socket = -1;
}
inline native_socket_t get_socket() const
inline native_socket_type get_socket() const
{
return m_socket;
}
......@@ -639,7 +639,7 @@ void post_office_loop(int pipe_read_handle, int pipe_write_handle)
case close_socket_event:
{
DEBUG("close_socket_event");
auto sockfd = static_cast<native_socket_t>(pmsg[1]);
auto sockfd = static_cast<native_socket_type>(pmsg[1]);
auto end = peers.end();
auto i = std::find_if(peers.begin(), end,
[sockfd](po_peer& peer) -> bool
......@@ -691,7 +691,7 @@ void post_office_loop(int pipe_read_handle, int pipe_write_handle)
* (forward each function call to our queue) *
******************************************************************************/
void post_office_add_peer(native_socket_t a0,
void post_office_add_peer(native_socket_type a0,
const process_information_ptr& a1,
const actor_proxy_ptr& a2,
std::unique_ptr<attachable>&& a3)
......@@ -703,7 +703,7 @@ void post_office_add_peer(native_socket_t a0,
write(nm->write_handle(), msg, pipe_msg_size);
}
void post_office_publish(native_socket_t server_socket,
void post_office_publish(native_socket_type server_socket,
const actor_ptr& published_actor)
{
DEBUG("post_office_publish(" << published_actor->id() << ")");
......@@ -722,7 +722,7 @@ void post_office_unpublish(actor_id whom)
write(nm->write_handle(), msg, pipe_msg_size);
}
void post_office_close_socket(native_socket_t sfd)
void post_office_close_socket(native_socket_type sfd)
{
auto nm = singleton_manager::get_network_manager();
pipe_msg msg = { close_socket_event, static_cast<std::uint32_t>(sfd) };
......
......@@ -2,7 +2,7 @@
namespace cppa { namespace detail {
post_office_msg::add_peer::add_peer(native_socket_t peer_socket,
post_office_msg::add_peer::add_peer(native_socket_type peer_socket,
const process_information_ptr& peer_ptr,
const actor_proxy_ptr& peer_actor_ptr,
std::unique_ptr<attachable>&& peer_observer)
......@@ -13,14 +13,14 @@ post_office_msg::add_peer::add_peer(native_socket_t peer_socket,
{
}
post_office_msg::add_server_socket::add_server_socket(native_socket_t ssockfd,
post_office_msg::add_server_socket::add_server_socket(native_socket_type ssockfd,
const actor_ptr& whom)
: server_sockfd(ssockfd)
, published_actor(whom)
{
}
post_office_msg::post_office_msg(native_socket_t arg0,
post_office_msg::post_office_msg(native_socket_type arg0,
const process_information_ptr& arg1,
const actor_proxy_ptr& arg2,
std::unique_ptr<attachable>&& arg3)
......@@ -30,7 +30,7 @@ post_office_msg::post_office_msg(native_socket_t arg0,
new (&m_add_peer_msg) add_peer(arg0, arg1, arg2, std::move(arg3));
}
post_office_msg::post_office_msg(native_socket_t arg0, const actor_ptr& arg1)
post_office_msg::post_office_msg(native_socket_type arg0, const actor_ptr& arg1)
: next(nullptr)
, m_type(add_server_socket_type)
{
......
......@@ -31,7 +31,7 @@ namespace cppa {
namespace {
void read_from_socket(detail::native_socket_t sfd, void* buf, size_t buf_size)
void read_from_socket(detail::native_socket_type sfd, void* buf, size_t buf_size)
{
char* cbuf = reinterpret_cast<char*>(buf);
size_t read_bytes = 0;
......@@ -58,11 +58,11 @@ struct socket_guard
{
bool m_released;
detail::native_socket_t m_socket;
detail::native_socket_type m_socket;
public:
socket_guard(detail::native_socket_t sfd) : m_released(false), m_socket(sfd)
socket_guard(detail::native_socket_type sfd) : m_released(false), m_socket(sfd)
{
}
......@@ -81,10 +81,10 @@ struct socket_guard
void publish(actor_ptr& whom, std::uint16_t port)
{
if (!whom) return;
detail::native_socket_t sockfd;
detail::native_socket_type sockfd;
struct sockaddr_in serv_addr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
if (sockfd == detail::invalid_socket)
{
throw network_error("could not create server socket");
}
......@@ -123,11 +123,11 @@ void publish(actor_ptr&& whom, std::uint16_t port)
actor_ptr remote_actor(const char* host, std::uint16_t port)
{
detail::native_socket_t sockfd;
detail::native_socket_type sockfd;
struct sockaddr_in serv_addr;
struct hostent* server;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
if (sockfd == detail::invalid_socket)
{
throw network_error("socket creation failed");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment