Commit 627cec59 authored by neverlord's avatar neverlord

fixed mailman implementation

parent 2583d715
......@@ -201,8 +201,6 @@ cppa/util/any_tuple_iterator.hpp
src/any_tuple_iterator.cpp
cppa/detail/boxed.hpp
cppa/detail/unboxed.hpp
cppa/detail/matcher_arguments.hpp
src/matcher_arguments.cpp
src/invoke_rules.cpp
src/abstract_tuple.cpp
cppa/util/duration.hpp
......
......@@ -172,6 +172,8 @@ class actor : public channel
*/
static intrusive_ptr<actor> by_id(std::uint32_t actor_id);
inline bool is_proxy() const { return m_is_proxy; }
};
/**
......
......@@ -32,8 +32,9 @@ class actor_proxy_cache
public:
// this callback is called if a new proxy instance is created
template<typename F>
void set_callback(F&& cb)
void set_new_proxy_callback(F&& cb)
{
m_new_cb = std::forward<F>(cb);
}
......
......@@ -17,6 +17,13 @@ class post_office_msg
public:
enum msg_type
{
add_peer_type,
add_server_socket_type,
proxy_exited_type
};
struct add_peer
{
......@@ -42,6 +49,12 @@ class post_office_msg
};
struct proxy_exited
{
actor_proxy_ptr proxy_ptr;
inline proxy_exited(const actor_proxy_ptr& who) : proxy_ptr(who) { }
};
post_office_msg(native_socket_t arg0,
const process_information_ptr& arg1,
const actor_proxy_ptr& arg2,
......@@ -49,14 +62,21 @@ class post_office_msg
post_office_msg(native_socket_t arg0, const actor_ptr& arg1);
post_office_msg(const actor_proxy_ptr& proxy_ptr);
inline bool is_add_peer_msg() const
{
return m_is_add_peer_msg;
return m_type == add_peer_type;
}
inline bool is_add_server_socket_msg() const
{
return !m_is_add_peer_msg;
return m_type == add_server_socket_type;
}
inline bool is_proxy_exited_msg() const
{
return m_type == proxy_exited_type;
}
inline add_peer& as_add_peer_msg()
......@@ -69,27 +89,32 @@ class post_office_msg
return m_add_server_socket;
}
inline proxy_exited& as_proxy_exited_msg()
{
return m_proxy_exited;
}
~post_office_msg();
private:
post_office_msg* next;
bool m_is_add_peer_msg;
msg_type m_type;
union
{
add_peer m_add_peer_msg;
add_server_socket m_add_server_socket;
proxy_exited m_proxy_exited;
};
};
constexpr std::uint32_t rd_queue_event = 0x00;
constexpr std::uint32_t unpublish_actor_event = 0x01;
constexpr std::uint32_t dec_socket_ref_event = 0x02;
constexpr std::uint32_t close_socket_event = 0x03;
constexpr std::uint32_t shutdown_event = 0x04;
constexpr std::uint32_t close_socket_event = 0x02;
constexpr std::uint32_t shutdown_event = 0x03;
typedef std::uint32_t pipe_msg[2];
constexpr size_t pipe_msg_size = 2 * sizeof(std::uint32_t);
......
......@@ -38,22 +38,27 @@ void actor_proxy::enqueue(actor* sender, any_tuple&& msg)
void actor_proxy::enqueue(actor* sender, const any_tuple& msg)
{
/*
if (msg.size() > 0 && msg.utype_info_at(0) == typeid(atom_value))
{
if (msg.size() == 2 && msg.utype_info_at(1) == typeid(actor_ptr))
{
switch (to_int(msg.get_as<atom_value>(0)))
{
// received via post_office
case to_int(atom(":Link")):
{
auto s = msg.get_as<actor_ptr>(1);
link_to(s);
(void) link_to_impl(s);
//link_to(s);
return;
}
// received via post_office
case to_int(atom(":Unlink")):
{
auto s = msg.get_as<actor_ptr>(1);
unlink_from(s);
(void) unlink_from_impl(s);
//unlink_from(s);
return;
}
default: break;
......@@ -67,6 +72,15 @@ void actor_proxy::enqueue(actor* sender, const any_tuple& msg)
return;
}
}
*/
if ( msg.size() == 2
&& msg.utype_info_at(0) == typeid(atom_value)
&& msg.get_as<atom_value>(0) == atom(":KillProxy")
&& msg.utype_info_at(1) == typeid(std::uint32_t))
{
cleanup(msg.get_as<std::uint32_t>(1));
return;
}
forward_message(parent_process_ptr(), sender, msg);
}
......
......@@ -56,11 +56,7 @@ mailman_job::~mailman_job()
/*
// implemented in post_office.cpp
util::single_reader_queue<mailman_job>& mailman_queue()
{
return *s_queue;
//return *(s_mailman_manager.m_queue);
}
util::single_reader_queue<mailman_job>& mailman_queue();
*/
// known issues: send() should be asynchronous and select() should be used
......
This diff is collapsed.
......@@ -25,27 +25,45 @@ post_office_msg::post_office_msg(native_socket_t arg0,
const actor_proxy_ptr& arg2,
std::unique_ptr<attachable>&& arg3)
: next(nullptr)
, m_is_add_peer_msg(true)
, m_type(add_peer_type)
{
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)
: next(nullptr)
, m_is_add_peer_msg(false)
, m_type(add_server_socket_type)
{
new (&m_add_server_socket) add_server_socket(arg0, arg1);
}
post_office_msg::post_office_msg(const actor_proxy_ptr& proxy_ptr)
: next(nullptr)
, m_type(proxy_exited_type)
{
new (&m_proxy_exited) proxy_exited(proxy_ptr);
}
post_office_msg::~post_office_msg()
{
if (m_is_add_peer_msg)
{
m_add_peer_msg.~add_peer();
}
else
switch (m_type)
{
m_add_server_socket.~add_server_socket();
case add_peer_type:
{
m_add_peer_msg.~add_peer();
break;
}
case add_server_socket_type:
{
m_add_server_socket.~add_server_socket();
break;
}
case proxy_exited_type:
{
m_proxy_exited.~proxy_exited();
break;
}
default: throw std::logic_error("invalid post_office_msg type");
}
}
......
......@@ -88,7 +88,7 @@ void publish(actor_ptr& whom, std::uint16_t port)
{
throw network_exception("could not create server socket");
}
// closes the socket if an exception occurs
// sguard closes the socket if an exception occurs
socket_guard sguard(sockfd);
memset((char*) &serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
......
......@@ -649,7 +649,7 @@ class uniform_type_info_map_helper
insert(d, new channel_ptr_tinfo, { raw_name<channel_ptr>() });
//insert(d, new message_tinfo, { raw_name<any_tuple>() });
insert(d, new atom_value_tinfo, { raw_name<atom_value>() });
insert(d, new addr_msg_tinfo, { raw_name<addr_msg_tinfo>() });
insert(d, new addr_msg_tinfo, {raw_name<detail::addressed_message>()});
insert<float>(d);
insert<cppa::util::void_type>(d);
if (sizeof(double) == sizeof(long double))
......
......@@ -42,7 +42,6 @@ void client_part(const std::map<std::string, std::string>& args)
size_t test__remote_actor(const char* app_path, bool is_client,
const std::map<std::string, std::string>& args)
{
return 0;
if (is_client)
{
client_part(args);
......@@ -70,7 +69,7 @@ size_t test__remote_actor(const char* app_path, bool is_client,
std::string cmd;
{
std::ostringstream oss;
oss << app_path << " run=remote_actor port=" << port << " &>/dev/null";
oss << app_path << " run=remote_actor port=" << port << " &>remote.txt" ;//" &>/dev/null";
cmd = oss.str();
}
// execute client_part() in a separate process,
......
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