ei_rpc - pro and con, patch offered

Hal Snyder <>
Wed Sep 3 21:27:27 CEST 2003


Here are some comments, and a proposed patch, for ei_rpc, the C/C++
interface to OTP's RPC service. They are based on OTP-R9C-0, with tests
run on FreeBSD-5.0.

We expect to go ahead with ei_rpc on the current project. Btw, UBF
lurks around the same problem space and may be introduced at any time.

The main reason to use ei_rpc:

   If you already have working services or databases on OTP, they
   become readily accessible to C and C++ with little or no code added
   to the OTP parts of your enterprise.

   Within OTP, it is common to wrap a message-based or mnesia-based
   subsystem with an API so that outsiders do not need to access
   internal message and table implementations. Using rpc allows
   external nodes to use an existing functional API.

Costs of ei_rpc:

1. C node must respond to ERL_TICK messages - while the response code
   is provided within the ei library, that code must be called by a
   listener thread or equivalent within the C node.

2. If thread-safety is a concern, the socket descriptor for each
   remote OTP node connection must be guarded by a mutexe.

3. If it is not acceptable for a client to block indefinitely on an
   rpc request, timeouts must be used. In that case, a response to an
   RPC call could belong to a previously issued query. In addition,
   responses can arrive out of order. Thus it is necessary to:

   a. carry transaction id in request and result

   and

   b. create client-side code for pairing requests with responses and
      scavenging both as needed


The patch.

Item 3a. can be eliminated if using the patch below, which also
includes the nfds patch offered previously on this mailing list.
The patch eliminates an apparently gratuitous setting of
self.pid.num to the remote file descriptor. That gives us a 15-bit
field in the C node (virtual) erlang_pid to use as transaction ID,
thus:

     ecn.self.num = transaction_id;
     result = ei_rpc_to(&ecn, remote_fd, mod, func, args.buff, args.index);

   ...

     result = ei_rpc_from(&ecn, remote_fd, timeout_msec, &msg, &rpc_result);
     ... check for ERL_MSG result ...
     ... then match msg.to.num with transaction_id on query ...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ei_connect.c.patch
Type: text/x-patch
Size: 949 bytes
Desc: ei_connect.c patch
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20030903/8437b91a/attachment.bin>
-------------- next part --------------

Comments?


More information about the erlang-questions mailing list