ammoQ ammoQ - 27 days ago 7
Groovy Question

Why does an RPC call fail in a C program called from Groovy on Linux?

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?

Answer

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.

Comments