More changes for scan corrections and unit test coverage
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / sipoll.c
index 8c28977..6c8915a 100644 (file)
 
 extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
 {
- //extern int deaths;       //  number of children that died and are zombies
- //extern int sigflags;     //  flags set by the signal handler routine
-
  int fd;                       //  file descriptor for use in this routine
  int ((*cbptr)());             //  pointer to callback routine to call
  int status = SI_OK;              //  return status
- int addrlen;                  //  length of address from recvfrom call
- char *buf;                   //  work buffer pointer
+ int addrlen = 0;              //  length of address from recvfrom call
+ char *buf;                           //  work buffer pointer
  char ibuf[1025];
  int i;                        //  loop index
  struct tp_blk *tpptr;         //  pointer at tp stuff
@@ -77,36 +74,12 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
     pstat = select( gptr->fdcount, &gptr->readfds, &gptr->writefds,
                                &gptr->execpfds, &delay );
 
-   if( (pstat < 0 && errno != EINTR)  )
+   if( pstat < 0 && errno != EINTR  )
     {                             //  poll fail or termination signal rcvd
      gptr->fdcount = 0;           //  prevent trying to look at a session
      gptr->flags |= GIF_SHUTDOWN; //  cause cleanup and exit at end
-     //deaths = 0;                  //  dont need to issue waits on dead child
-     //sigflags = 0;                //  who cares about signals now too
     }
 
-/*
-   while( deaths > 0 )  //  there have been death(s) - keep the dead
-    {                   //  from being zombies - send them to heaven
-     wait( NULL );                       //  issue wait on child
-     deaths--;
-    }                   //  end while dead children to send to heaven
-*/
-
-/*
-  if( sigflags &&        //  if signal received and processing them
-     (cbptr = gptr->cbtab[SI_CB_SIGNAL].cbrtn) != NULL )
-   {
-    while( sigflags != 0 )
-     {
-      i = sigflags;                  //  hold for call
-      sigflags = 0;                  //  incase we are interrupted while away
-      status = (*cbptr)( gptr->cbtab[SI_CB_SIGNAL].cbdata, i );
-      SIcbstat( gptr, status, SI_CB_SIGNAL );    //  handle status
-     }                                           //  end while
-   }
-*/
-
    if( pstat > 0  &&  (! (gptr->flags & GIF_SHUTDOWN)) )
     {
      if( FD_ISSET( 0, &gptr->readfds ) )       //  check for keybd input
@@ -119,7 +92,6 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
         }                                 //  end if call back was defined
       }
 
-     // for( tpptr = gptr->tplist; tpptr != NULL; tpptr = tpptr->next )
        tpptr = gptr->tplist; 
        while( tpptr != NULL ) {
                nextone = tpptr->next;                                  //  allow for a delete in loop
@@ -138,7 +110,7 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
 
          if( tpptr->flags & TPF_LISTENFD )     //  listen port setup by init?
           {                                    //  yes-assume new session req
-           status = SInewsession( gptr, tpptr );    //  make new session
+           SInewsession( gptr, tpptr );                   //  cannot do anything about failure, so ignore status
           }
          else                              //  data received on a regular port
           if( tpptr->type == SOCK_DGRAM )          //  udp socket?
@@ -153,6 +125,7 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
                 status = (*cbptr)( gptr->cbtab[SI_CB_RDATA].cbdata, gptr->rbuf, status, buf );
                 SIcbstat( gptr, status, SI_CB_RDATA );    //  handle status
                                free( buf );
+                               buf = NULL;                                             // just to be safe
                }                              //  end if call back was defined
              }                                //  end if status was ok
             free( uaddr );