[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference lassie::ucx

Title:DEC TCP/IP Services for OpenVMS
Notice:Note 2-SSB Kits, 3-FT Kits, 4-Patch Info, 7-QAR System
Moderator:ucxaxp.ucx.lkg.dec.com::TIBBERT
Created:Thu Nov 17 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:5568
Total number of notes:21492

5451.0. "select sets ef 63 arbitrarily" by CSC32::J_HENSON (Don't get even, get ahead!) Thu Apr 17 1997 13:15

ucx 4.1 eco 4, openvms alpha v6.2

It appears that a recent change to ucx has resulted in the select
routine ALWAYS setting local event flag 63 on a timeout (and perhaps
on a normal completion.).  I have attached a command procedure that
can be used to reproduce this to the bottom of this note, as well as
the output I get when running this procedure.  Please note that 
the code I used is a modification of ucx$examples:ucx$udp_server_socket.c.

In the example, I call lib$get_ef until I successfully allocate event
flag 63.  This should be all that is necessary to successfully use
event flag 63 for another use.  In my customer's case, he was
using ef 63 (after calling lib$get_ef to allocate it) in a call
to sys$setimr.  The purpose of the time was to have a new log file
created every 24 hours.  In his case, he is also calling select
with a 45 second timeout, and is now getting a new log file every
45 seconds.

I believe that a workaround is to specifically NOT use ef 63 for anything.
If a call to lib$get_ef returns 63, call it again to get another event
flag, and then free event flag 63.  The free is probably not necessary,
but it makes for cleaner code.

Also, according to my customer, this does not occur with ucx 4.0 eco 1.

I will be IPMT'ing this as a severity 2 spr.

Jerry

===========================output of command procedure==================


  Digital TCP/IP Services for OpenVMS Alpha Version V4.1 - ECO Level 4
  on a AlphaServer 1000 4/200 running OpenVMS V6.2    

allocating EFs, i = 0, flag = 63, state = 1
After clearing event flag 63, state = 9
Select timed out with status 0.
readef status is 9, state value is DE000000
clref status is 9
After clearing, readef status is 1, state value is 5e000000
Select timed out with status 0.
readef status is 9, state value is DE000000
clref status is 9
After clearing, readef status is 1, state value is 5e000000
Select timed out with status 0.
readef status is 9, state value is DE000000
clref status is 9
After clearing, readef status is 1, state value is 5e000000


====================procedure to reproduce problem================

$ucx sho version
$create udp_server.c
/*====================================================================
*
*			  COPYRIGHT (C) 1989 BY
*	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
*
* This software is furnished under a license and may be used and  copied
* only  in  accordance  with  the  terms  of  such  license and with the
* inclusion of the above copyright notice.  This software or  any  other
* copies  thereof may not be provided or otherwise made available to any
* other person.  No title to and ownership of  the  software  is  hereby
* transferred.
*
* The information in this software is subject to change  without  notice
* and  should  not  be  construed  as  a commitment by DIGITAL EQUIPMENT
* CORPORATION.
*
* DIGITAL assumes no responsibility for the use or  reliability  of  its
* software on equipment which is not supplied by DIGITAL.
*
*
*
*  FACILITY:
*	INSTALL 
*      
*
*  ABSTRACT:
*	This is an example of a UDP/IP server using the IPC 
*	socket interface.
*      
*
*  ENVIRONMENT:
*	UCX V1.2 or higher, VMS V5.2 or higher 
*
*	This example is portable to Ultrix. The include
*	files are conditionally defined for both systems, and 
*	"perror" is used for error reporting.
*
*  BUILD INSTRUCTIONS:
*
*       To link in VAXC/VMS you must have the following
*       entries in your .opt file:
*          sys$library:ucx$ipc.olb/lib
*          sys$share:vaxcrtl.exe/share
*
*       For DEC C or DEC C++, compile /PREFIX=ALL and link via
*          $ link UCX$UDP_SERVER_IPC
*
*    To build this example program use commands of the form,
*
*        using the DEC "C" compiler:
*
*            $ cc/prefix=all UCX$UDP_SERVER_IPC.C
*            $ link UCX$UDP_SERVER_IPC
*    
*        using the DEC "C++" compiler:
*    
*            $ cxx/prefix=all/define=VMS UCX$UDP_SERVER_IPC.C
*            $ link UCX$UDP_SERVER_IPC
*    
*        using the VAX "C" compiler:
*    
*            $  cc /vaxc UCX$UDP_SERVER_IPC.C
*            $  link UCX$UDP_SERVER_IPC, -
*                    SYS$LIBRARY:UCX$IPC/LIB, -
*                    SYS$INPUT/OPTIONS
*            SYS$SHARE:UCX$IPC_SHR/SHARE
*            SYS$SHARE:VAXCRTL.EXE/SHARE
*    
*
*  AUTHORS:
*	UCX Developer	
*
*  CREATION DATE: May 23, 1989 
*
*  MODIFICATION HISTORY:
*
*       16 May 1996 Joseph J. Vlcek
*       Make compatible with the DEC C and DEC C++ compilers.
*       Add directions on how to build this example modules.
*
*/


/*
*
*  INCLUDE FILES
*
*/

#ifdef VMS
#include <descrip.h>        /* VMS descriptor stuff */
#include <errno.h>          /* Unix style error codes for IO routines. */
#include <in.h>             /* internet system Constants and structures. */
#include <inet.h>           /* Network address info. */
#include <iodef.h>          /* I/O FUNCTION CODE DEFS */
#include <lib$routines.h>   /* LIB$ RTL-routine signatures. */
#include <netdb.h>          /* Network database library info. */
#include <signal.h>         /* UNIX style Signal Value Definitions */
#include <socket.h>         /* TCP/IP socket definitions. */
#include <ssdef.h>          /* SS$_<xyz> sys ser return stati <8-) */
#include <starlet.h>        /* Sys ser calls */
#include <stdio.h>          /* UNIX 'Standard I/O' Definitions   */
#include <stdlib.h>         /* General Utilities */
#include <string.h>         /* String handling function definitions */
#include <ucx$inetdef.h>    /* UCX network definitions */
#include <unixio.h>         /* Prototypes for UNIX emulation functions */

#else
#include <errno.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/uio.h>
#include <time.h>		/* timeval declared here */
#endif



/*-----------------------------------------------------------*/

cleanup( int socket )
{
	int	retval;


	/*
	 * Shutdown socket  completely.
	 */
	retval = shutdown(socket,2);
	if (retval == -1)
		perror ("shutdown");


	/*
	 * Close socket.
	 */
        retval = close (socket);
	if (retval)
		perror ("close");

	exit( 1 );


} /* end cleanup */



/*
* Functional Description
*
*	This example creates a socket of type SOCK_DGRAM (UDP), binds 
*	it, and selects to receive a message on the socket.
*	Error messages are printed to the screen.
*
*	IPC calls used: 
*	bind
*	close
*	gethostbyname
*	recvfrom
*	select
*	shutdown
*	socket	
*
*
* Formal Parameters
*	The server program expects one parameter:
*	portnumber ... port where it is listening
*
*
* Routine Value
*
*	Status	
*/


/*--------------------------------------------------------------------*/
main( int argc, char **argv )
{
	int	event,state,events[32],i,imax;
	int     rmask, wmask, emask;
        int     sock_2;               	/* Socket 2  descriptor.       */
        int     buflen,fromlen;
        char    recvbuf[BUFSIZ];
static  struct  sockaddr_in sock1_name;    	/* Address struct for socket1.*/
static  struct  sockaddr_in sock2_name;    	/* Address struct for socket2.*/
        int 	namelength;
        struct  hostent         hostentstruct;  /* Storage for hostent data.  */
        struct  hostent         *hostentptr;    /* Pointer to hostent data.   */
        static  char            hostname[256];  /* Name of local host.        */
	int	retval;
	int	flag;
	struct  timeval 	timeout;	


	/*
	 * Check input parameters
	 */
        if (argc != 2 )
		{
                printf("Usage: server portnumber.\n");
		exit( 1 );
		}


	/*
	 * Open socket 2: AF_INET, SOCK_DGRAM. 
	 */
        if ((sock_2 = socket (AF_INET, SOCK_DGRAM, 0)) == -1) 
		{
                perror( "socket");
		exit( 1 );
		}


	/*
	 * Get the local host  name. 
	 */
        retval = gethostname(hostname,sizeof hostname);
        if (retval)
		{
                perror ("gethostname");
		cleanup(sock_2);
	 	}
	

	/*
	 * Get pointer to network data structure for local host. 
	 */
        if ((hostentptr = gethostbyname (hostname)) == NULL) 
		{
                perror( "gethostbyname");
		cleanup(sock_2);
	 	}


	/*
	 * Copy hostent data to safe storage. 
	 */
        hostentstruct = *hostentptr;


	/*
	 * Fill in the address structure for socket 2.
	 */ 
        sock2_name.sin_family = hostentstruct.h_addrtype;
        sock2_name.sin_port = htons(atoi(argv[1])); 
        sock2_name.sin_addr = * ((struct in_addr *) hostentstruct.h_addr);


	/*
	 * Bind name to socket 2. 
	 */
        retval = bind ( sock_2,
                        (struct sockaddr*)&sock2_name,
                        sizeof sock2_name );
        if (retval)                       
		{
                perror("bind");
		cleanup(sock_2);
	 	}


	/*
	 * Select socket to receive message.
	 */ 
	emask = wmask = 0; 
	rmask = (1<<sock_2);  /* set read mask */
	timeout.tv_sec = 5;
	timeout.tv_usec = 0;
/*
**  call lib$get_ef until we allocate event flag 63.
**  free all other event flags than 63, and make sure that 63 is clear
**/
	for (i=0;i<32;i++)
	{
	 state = lib$get_ef(&events[i]);
	 printf("allocating EFs, i = %d, flag = %d, state = %d\n",
		i,events[i],state);
	 if (events[i] == 63) 
	 {
	   state = sys$clref(63);
	   printf("After clearing event flag 63, state = %d\n",state);
	   imax = i;
	   goto free_ef;
	 }
	}
free_ef:
	for (i=0;i<imax;i++)
	{
	  state = lib$free_ef(&events[i]);
	  printf("freeing EFs, i = %d, flag = %d, state = %d\n",
		i,events[i],state);
	}
	   

select:	
	retval = select( 32, &rmask, &wmask, &emask, &timeout );
	switch (retval)
	{
	  case -1:
		{
                perror("select");
		cleanup(sock_2);
		}
	  case 0:
		{
                printf("Select timed out with status 0.\n");
		event = sys$readef(63,&state);
		printf("readef status is %d, state value is %X\n",
			event,state);
		state = sys$clref(63);
	   	printf("clref status is %d\n",state);
	  	event = sys$readef(63,&state);
		printf(
		"After clearing, readef status is %d, state value is %x\n",
		event,state);
		goto select;
		}
	  default:
		if ((rmask & (1<<sock_2)) == 0)
			{
			printf("Select not reading on sock_2.\n");
			cleanup(sock_2); 
			}
	} /*switch*/



	/*
	 * Recvfrom buffer - from sock1 on sock2. 
	 */
	buflen = sizeof(recvbuf);
	fromlen = sizeof(sock1_name);
	flag = 0;	/* flag may be MSG_OOB and/or MSG_PEEK */

	retval = recvfrom( sock_2,
                           recvbuf,
                           buflen,
                           flag,
                           (struct sockaddr*)&sock1_name,
                           &fromlen);
        if (retval == -1)
                perror("recvfrom");
	   else
		printf (" %s\n", recvbuf);

	/*
	 * Call cleanup to shutdown and close socket.
	 */
	cleanup(sock_2);

 } /* end main */
$cc/standard=vaxc  udp_server
$link udp_server
$udp_server:==$user1:[j_henson]udp_server   !modify to reflect your directory
$udp_server 4000

T.RTitleUserPersonal
Name
DateLines
5451.1Yeah!LADDIE::TIBBERTLee Tibbert, DTN 226-6115Thu Apr 17 1997 15:2620
> I will be IPMT'ing this as a severity 2 spr.

This is what I love to see, the synergy of NOTES 
followed up by formal mechanisms.  Thanks Jerry, you
made my day.

I thought that Myth fixed this recently for another
IPMT case. 

You could check the release notes for 4.1 ECO7?
Do you have PAT7 and a system to test it on?

I'm not his keeper (rather it is the other way around ;-))
but I think that he is unavailable for a while.

Nice bug, eh? Pretty embarassing here.

I hope this helps,

Lee
5451.2can't find eco 7CSC32::J_HENSONDon&#039;t get even, get ahead!Fri Apr 18 1997 09:4022
>>       <<< Note 5451.1 by LADDIE::TIBBERT "Lee Tibbert, DTN 226-6115" >>>
>>                                   -< Yeah! >-

>>This is what I love to see, the synergy of NOTES 
>>followed up by formal mechanisms.  Thanks Jerry, you
>>made my day.

Always glad to do my part. ;-)

>>You could check the release notes for 4.1 ECO7?
>>Do you have PAT7 and a system to test it on?

I looked for this eco, but couldn't find it.  The latest ucx eco in
the CSC database is ucx 4.1 eco 4.  I looked in lassie::ucx$eco:,
and couldn't find anything later and eco 4.

Do you have a pointer, or know when this eco will be made officially
available?

Thanks,

Jerry
5451.3LASSIE::UCX$INTERNAL:*PAT7*.*CSC32::R_WILLIAMSFri Apr 18 1997 10:021
    
5451.4PATs are experimentalLADDIE::TIBBERTLee Tibbert, DTN 226-6115Fri Apr 18 1997 13:2926
It can get confusing (and my typo in .-2 did not help, 
There is a PAT7, but ECO7 is not yet even a dream).

PATs are trial, experimental ECO kits. We _think_ they
are OK, but their purpose is to discover unexpected
ramifications to proposed fixes.  They are probably
OK to run on non-critical Digital Internal machines,
but should not be given to customers unless explicitly
instructed by Natasha (or a UCX engineer).


ECO kits (in UCX$ECO) are explicitly for customer release.
They have gone through a longer qualification process.
They are riskier than SSB baseline version releases but
much less so than PAT kits.

Make sense?

When I'm problem solving on customer system and see that the
latest ECO is not applied, my usual response is to ask that it
be installed.  Now, when in the same situation, I see a PAT kit
installed, I call home and say that I'll be way late for dinner 
(well, breakfast) ;-)

Lee
5451.5how about this?CSC32::J_HENSONDon&#039;t get even, get ahead!Fri Apr 18 1997 15:5513
>>       <<< Note 5451.4 by LADDIE::TIBBERT "Lee Tibbert, DTN 226-6115" >>>
>>                           -< PATs are experimental >-

>>It can get confusing (and my typo in .-2 did not help, 
>>There is a PAT7, but ECO7 is not yet even a dream).

If I can get permission from the system manager of our test system, I'll
try pat7 (or at least check the release notes).  Then, I'll add the
results of that to the ipmt and elevate it.

Does that sound ok?

Jerry
5451.6duplicate of hpxq10394CSC32::J_HENSONDon&#039;t get even, get ahead!Fri Apr 18 1997 17:1130
>>       <<< Note 5451.5 by CSC32::J_HENSON "Don't get even, get ahead!" >>>
>>                              -< how about this? >-

>>If I can get permission from the system manager of our test system, I'll
>>try pat7 (or at least check the release notes).  Then, I'll add the
>>results of that to the ipmt and elevate it.

Ok.  I think I've got this wired.

I read the release notes and it documents a problem with linking against
the wrong/static version of lib$get_ef or something similar.  This was
fixed in ucx v4.1/eco 5/eco a.  Using COMET, I found where this was
previously IPMT'ed as field service number HPXQ10394.  The release
notes mention a cfs.47810 number, but, according to COMET, this was
an spr against vms and the $adjwsl system service.

Anyway, according to the spr (spr'ed under c961219-5807. and documented
in note 5057 of this very conference.  How'd I miss that?), the eco 5
patch installs a new ucx$ipc_shr.exe, which is located at
lassie::ucx$internal:ucx$ipc_shr.exe_eco_a__v41_axp_v61.;1.  I
pulled just this image, and ran my test program against it simply
by defining ucx$ipc_shr to point to this image.  When I did this,
I got different results which suggest that this shareable has
fixed the problem.

So, for sake of documentation, and to make sure that nothing slips
through the cracks, I will elevate this as a duplicate of
hpxq10394.

Jerry
5451.7This will make Myth's dayLADDIE::TIBBERTLee Tibbert, DTN 226-6115Fri Apr 18 1997 18:217
Myth will be glad to hear that his work is being used by
somebody.  Sorry that the fixed image did not get through
the ECO pipe to your sooner, so that you would not
have encountered this problem.

Lee
5451.8when?CSC32::J_HENSONDon&#039;t get even, get ahead!Wed Apr 23 1997 10:1624
>>       <<< Note 5451.7 by LADDIE::TIBBERT "Lee Tibbert, DTN 226-6115" >>>
>>                         -< This will make Myth's day >-


>>Myth will be glad to hear that his work is being used by
>>somebody.  Sorry that the fixed image did not get through
>>the ECO pipe to your sooner, so that you would not
>>have encountered this problem.

Lee,

Do you have an estimate as to when this fix will be released as part
of an official eco?  Because the earlier ipmt elevation has already
been close, I am unable to elevate this as a duplicate.  I have to
either elevate it as a new issue (with pointers to the old case),
or not elevate at all.

If the fix will soon be available, I'd just as soon wait for it and
not do the elevation.  On the other hand, if another elevation is
necessary to get the eco through official channels, I can do that.

Thanks,

Jerry
5451.9Very soon.LADDIE::TIBBERTLee Tibbert, DTN 226-6115Thu Apr 24 1997 18:0115
UCX 4.1 PAT 8 is about to hit the streets in a few
minutes.  If we get good feedback on that PAT kit,
it will be submitted to TIMA. 

Since it can take a while to go through TIMA, we usually
post an unofficial copy of ECO kits in UCX$ECO. As always,
TIMA is the official kit.

My un-informed guess, not a promise, is two weeks to UCX$ECO, then  ??
until out of TIMA.

Does this do anything good for your customer? Please advise,

Lee
5451.10I can waitCSC32::J_HENSONDon&#039;t get even, get ahead!Fri Apr 25 1997 11:0621
>>       <<< Note 5451.9 by LADDIE::TIBBERT "Lee Tibbert, DTN 226-6115" >>>
>>                                -< Very soon. >-


>>My un-informed guess, not a promise, is two weeks to UCX$ECO, then  ??
>>until out of TIMA.

>>Does this do anything good for your customer? Please advise,

Lee,

My customer will use the workaround, so he is probably ok with this.
Mostly, I was trying to determine if I should go in a hold patter
waiting for the kit or re-elevate the issue.  If we're looking at
a 2-3 week time frame, and everything's already in the works, 
re-elevating probably will just slow everything down.  So, I'll
do the holding pattern thing.

Thanks for the update.

Jerry