3

在我们支持多平台(Linux、Solaris 和 Windows)并使用 C 和 C++ 编码的项目中,我们使用ONC RPC进行 IPC。最近需要有一个应用程序服务器来处理两个不同的程序。

我尝试了以下测试。

创建了一个多线程应用程序在其中创建了两个工作线程

    In first thread I’m
         a) Creating a TCP transport
         b) Registering the transport
         c) Calling svc_run

    In second thread I’
         a) Creating a second TCP transport
         b) Registering the transport with a different program no
         c) Calling svc_run*

我已经在Red Hat Linux 4 上尝试过了,它对我来说运行良好。

但是注册两个程序 no 并在两个不同的线程中调用 svc_run 是否有效?

我曾尝试在互联网上搜索,但我无法找到任何明确的信息。

4

1 回答 1

2

尽管我自己从未尝试过,但这似乎是合乎逻辑的。

请不要使用 IDL 编译器的-M命令开关rpcgen(来自其man在 Solaris 上的页面):

 -M          Generates multithread-safe stubs for passing
             arguments   and   results   between  rpcgen-
             generated code and user written  code.  This
             option  is useful  for users who want to use
             threads in their code.

如果代理/存根代码是线程安全的,并且您使用 2 个不同的 RPC 进程号注册了两个事件循环——我猜这应该表现得好像您实际上有 2 个不同的进程(RPC 方式)。

于 2009-12-14T09:13:02.677 回答