我需要创建一个能够同时处理来自客户端的多个请求的并发 RPC 服务器。
在 linux 中使用rpcgen
编译器(基于 sun RPC),它不支持-A
为并发服务器创建存根的选项。(该-A
选项在 solaris 中可用)
感谢有人可以提供一些想法:
- 在linux中创建并发RPC服务器的方法是什么。一些谷歌搜索建议在存根中进行更改,这不是一个好主意。
- 任何其他可用的 RPC 包 - sun rpc 的替代品。
It's such an old post and surely you will already have solved it, but it can be helpfull to somebody else:
In the "rpcgen" RPC compiler provided in the GNU toolchain the corresponding option is "-M
", for example:
rpcgen -M your_xdr_file.x
The change in the generated code is simple but elegant: the caller is who has to alloc the buffer where the client stub will write the response. This is the common behaviour in thread safe APIs. So will happen in the server stub, and there appears a hook in the server (called "PROGRAMNAME_VERSION_freeresult
") where you will have the opportunity to free all the resources that you could have allocated when executing the call in the server side.
Hope it helps someone!