[PATCH] rpc: fix server losing handler

1 view
Skip to first unread message

Avi Kivity

<avi@scylladb.com>
unread,
Jan 17, 2016, 4:32:57 AM1/17/16
to seastar-dev@googlegroups.com
We move 'func' away, but that happens to be the function that is used
for serving the verb, so if the function had movable state, it was lost
after one round.

The tests probably did not detect this because their handlers are stateless.

Found by Gleb.
---
rpc/rpc_impl.hh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rpc/rpc_impl.hh b/rpc/rpc_impl.hh
index 30ef02e..992248e 100644
--- a/rpc/rpc_impl.hh
+++ b/rpc/rpc_impl.hh
@@ -485,7 +485,7 @@ auto recv_helper(signature<Ret (InArgs...)> sig, Func&& func, WantClientInfo wci
auto memory_consumed = client->estimate_request_size(data.size());
auto args = unmarshall<Serializer, InArgs...>(client->serializer(), std::move(data));
// note: apply is executed asynchronously with regards to networking so we cannot chain futures here by doing "return apply()"
- return client->wait_for_resources(memory_consumed).then([client, msg_id, memory_consumed, args = std::move(args), func = std::forward<Func>(func)] () mutable {
+ return client->wait_for_resources(memory_consumed).then([client, msg_id, memory_consumed, args = std::move(args), &func] () mutable {
apply(func, client->info(), WantClientInfo(), signature(), std::move(args)).then_wrapped(
[client, msg_id, memory_consumed] (futurize_t<typename signature::ret_type> ret) mutable {
reply<Serializer, MsgType>(wait_style(), std::move(ret), msg_id, std::move(client), memory_consumed);
--
2.5.0

Commit Bot

<bot@cloudius-systems.com>
unread,
Jan 17, 2016, 7:20:37 AM1/17/16
to seastar-dev@googlegroups.com, Avi Kivity
From: Avi Kivity <a...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>

rpc: fix server losing handler

We move 'func' away, but that happens to be the function that is used
for serving the verb, so if the function had movable state, it was lost
after one round.

The tests probably did not detect this because their handlers are stateless.

Found by Gleb.

---
diff --git a/rpc/rpc_impl.hh b/rpc/rpc_impl.hh
Reply all
Reply to author
Forward
0 new messages