views:

52

answers:

3

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()

Any ideas what we could try to pinpoint and fix the problem?

+1  A: 

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

unwind
+1  A: 

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()
Aaron Digulla
+1  A: 

Dear ammoQ,

thanks for helping me with asking the question to the forum, also thanks to the contributors !

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.

best, dorgold

dorgold