为什么在 Linux 上从 Groovy 调用 C 程序时 RPC 调用失败?

发布于 2024-09-16 03:35:20 字数 620 浏览 11 评论 0原文

我们有一个用 C 编写的程序,它使用 RPC 与同一 Linux 服务器上的另一个程序(也用 C 编写)进行通信(在某些生产设置中,第二个 C 程序将在另一台机器上,因此使用 RPC 而不是 IPC)。

当从其他 C 程序、CRON 或命令行调用时,它会按预期工作,并且多年来一直如此,因此可以肯定地说它通常可以工作。

从 Groovy 脚本调用的同一个程序失败了,显然是由于网络问题。

在 C 程序中,svc_register(xprt, prognum, versnum,dispatch, protocol) 成功,但在

  • 请求后在 RPC 服务器上:clnttcp_create 失败,并显示“连接被拒绝
  • ” RPC 客户端等待回复: svc_fdset 上的 select 失败,并出现 EBADF

看的):

[ "myprogram", "someoption", "someprogram" ].execute()

Groovy 程序(只是为了完整性,这里没什么可 我们尝试查明并解决问题?

We have a program, written in C, that uses RPC to communicate with another program (also written in C) on the same Linux server (in some production setups, the second C program would on another machine, therefore RPC instead of IPC).

When called from other C programs, CRON or the command line, it works as expected and has been doing so for many years, so it's safe to say it generally works.

The same program, called from a Groovy script, fails, apparently with network problems.

In the C program, svc_register(xprt, prognum, versnum, dispatch, protocol) succeeds, but then

  • on the RPC server after request: clnttcp_create fails with "connection refused"
  • on the RPC client waiting for reply: select on svc_fdset fails with EBADF

Groovy program (just for completeness, not much to see here):

[ "myprogram", "someoption", "someprogram" ].execute()

What could we try to pinpoint and fix the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

哀由 2024-09-23 03:35:20

显然,从 Groovy 调用基于 RPC 的 C 程序确实有效。

问题可以缩小到“(int)sysconf (_SC_OPEN_MAX)”的问题,它用于确定 svc_fdset(用于从 rpc 请求获取回复的结构)中的 fd 数量,在使用时会失败由 Groovy 调用的 C 程序。

Apparently, calling RPC based C-programs from Groovy does indeed work.

The problem could be narrowed down to the issue that "(int)sysconf (_SC_OPEN_MAX)", which is used to determine the number of fds in svc_fdset (a structure used to get replies from rpc-requests) does fail in case of being used by a C program called from Groovy.

请叫√我孤独 2024-09-23 03:35:20

通过strace运行程序,看看有什么系统调用(s) 正在失败。

Run the program through strace, to see what system call(s) is/are failing.

無處可尋 2024-09-23 03:35:20

检查myprogram是否有输出或等待输入。如果您不读取输出或关闭输入,那么它将挂起,导致 RPC 调用超时。创建一个线程,读取 myprograminerr 并关闭 out

def p = [ "myprogram", "someoption", "someprogram" ].execute()
p.out.close()
p.consumeProcessOutput()

Check whether myprogram has output or waits for input. If you don't read the output or close the input, then it will hang, leading to timeouts in the RPC call. Create a thread which reads in and err of myprogram and close out:

def p = [ "myprogram", "someoption", "someprogram" ].execute()
p.out.close()
p.consumeProcessOutput()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文