[Info-vax] Hanging processes

Jess Goodman norebid at gmail.com
Sat Mar 28 13:37:19 EDT 2015


Tom Adams,

Sorry that I have not had time to look at this thread before, but hopefully I can still help,

I see one obvious problem in your code. SYS$CANCEL() is an asynchronous I/O operation. In other words, when SYS$CANCEL() returns the I/Os may still not have completed.

This creates a race-condition in your code which may be the cause of your intermittent failures.  And I would not be surprised if your MC$CMM_REDWRTTMO() routine had its own race-condition.

Assuming you are using the same event flag for both the $QIO and the $SETIMR calls and that your are not using ASTs, then your code should work like this:

unsigned short volatile iosb[4];
status = sys$qio( efn, conn_channel, IO$_ACCESS, iosb,.....
if (!(status&STS$M_SUCCESS)) return(status);

status = sys$setimr( efn, tmoivl, NULL, iosb, 0);
if (!(status&STS$M_SUCCESS)) return(status);
if (iosb[0] == 0)  /* In case I/O completed before we set timer */
  sys$waitfr(efn); /* Wait for IO completion or timer to expire */
if (iosb[0] == 0)  /* If efn is set by the timer iosb will be 0 */
{ sys$clref(efn); /* reclear event flag */
  status = sys$cancel(conn_channel);  /* Cancel I/O if still in progress */
  if (!(status&STS$M_SUCCESS)) return(status);
  if (iosb[0] == 0) /* In case I/O finished before clref */
    sys$waitfr(efn); /* because cancel is not always immediate */
  if (iosb[0]==SS$_ABORT || iosb[0]==SS$_CANCEL) iosb[0] = SS$_TIMEOUT;
}
else
  sys$cantim( iosb, 0); /* Cancel wakeup call (never errors) */
status = iosb[0];
return status;

J. Goodman
"I have one, but it's personal."


 
On Friday, February 20, 2015 at 9:12:45 AM UTC-5, Tom Adams wrote:
> Here's the module that attempts to connect to the analyzer:
>  
> /* pcs_ininetpot -- Initialize TCPIP Socket
<SNIP>
>        /*
>         * connect to specified host and port number
>         */
>        status = sys$qio( efn,	    	    /* event flag		    */
> 		       conn_channel,	    /* i/o channel		    */
> 		       IO$_ACCESS,	    /* i/o function code	    */
> 		       &iosb,		    /* i/o status block		    */
> 		       0,		    /* ast service routine	    */
> 		       0,		    /* ast parameter		    */
> 		       0,		    /* p1			    */
> 		       0,		    /* p2			    */
> 		       &serv_itemlst,	    /* p3 - remote socket name	    */
> 		       0,		    /* p4			    */
> 		       0,		    /* p5			    */
> 		       0		    /* p6			    */
> 		     );
> 
>        if ( status & STS$M_SUCCESS )
>        {
> 	status = cmm_watredwrtcpl (efn, tmoivl, efn, &iosb);
> 	if (status == MC$CMM_REDWRTTMO)
> 	{
> 	  status = SS$_TIMEOUT;
> 	  lclsts = sys$cancel(conn_channel);
> 	  /* close socket */
>           (void) sys$qiow( EFN$C_ENF,	    /* event flag		    */
> 		       conn_channel,	    /* i/o channel		    */
> 		       IO$_DEACCESS,	    /* i/o function code	    */
> 		       &iosb,		    /* i/o status block		    */
> 		       0,		    /* ast service routine	    */
> 		       0,		    /* ast parameter		    */
> 		       0,		    /* p1			    */
> 		       0,		    /* p2			    */
> 		       0,		    /* p3			    */
> 		       0,		    /* p4			    */
> 		       0,		    /* p5			    */
> 		       0		    /* p6			    */
> 		     );
<SNIP>



More information about the Info-vax mailing list