× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Pete,

I haven't used the signals technique from a CGI program. So I don't know what I'm talking about, I'm just going to guess!

I suspect that when Apache spawns the CGI jobs, it's specifying a signal mask that tells them to block the alarm signal (SIGALRM) that gets sent when the alarm() API's time limit expires?

That would explain the result you're seeing.

My suggestion is to eliminate the signal logic and replace it with (more complex, but also more robust) non-blocking socket logic.

HTH


On 6/22/2011 12:42 PM, Pete Helgren wrote:
I have an ILE RPG program is pretty simple: It checks to see if the port
at a certain host is online or not. It was written to demonstrate how to
call an RPG program from Java. It works fine when called from Java. I
wrote an ILE RPG 5250 program that calls the same program (CHK_PORT).
It works well in that ILE RPG program as well. So I am now using it in
a CGIDEV2 program and it works well if the host/port is online but if
the host is offline, the call times out rather than returns which causes
the CGIDEV2 program to fail.

The CHK_PORT program is based on some code from Scott Klements Sockets
programming tutorial (I think). The challenge in writing the program in
the first place was coding for the the failure of the connection when
the host or port was offline. I solved it using the following code:

C*************************************************
C* Connect to the requested host
C*************************************************
C/FREE
init_signals();

alarm(5);
if connect(sock: p_connto: addrlen)< 0;
msg = 'unable to connect to server!';
// dsply msg;
callp close(sock);
alarm(0);
port_status = '0';
return;
else;
msg = 'Host is online!';
port_status = '1';
// dsply msg;
endif;
/end-free

Again, the code works great when I call it from Java or from the ILE RPG
5250 program I wrote, but the CGIDEV2 program which calls the program
never seems to time out when the connection fails. This *seems* like an
activation group issue (?) but I can't quite figure out why an offline
host/port causes it to fail ONLY in the CGIDEV2 program call. In fact,
the code used in the CGIDEV2 program was a cut and paste from the 5250
program with slight modifications to accommodate the CGIDEV2 methods of
reading/writing to the output.

Any ideas on where to start tracking down the issue?



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.