Fix failure when in static only route table mode
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / sipoll.c
index df71eae..8c28977 100644 (file)
@@ -53,20 +53,16 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
  char ibuf[1025];
  int i;                        //  loop index
  struct tp_blk *tpptr;         //  pointer at tp stuff
- struct tp_blk *nextone;        //  pointer at next block to process
+ struct tp_blk *nextone = NULL;        //  pointer at next block to process
  int pstat;                    //  poll status
  int kstat;                    //  keyboard status
  struct timeval  delay;        //  delay to use on select call
  struct sockaddr *uaddr;       //  pointer to udp address
 
- gptr->sierr = SI_ERR_SHUTD;
-
  if( gptr->flags & GIF_SHUTDOWN )     //  cannot do if we should shutdown
   return( SI_ERROR );                    //  so just get out
 
 
- gptr->sierr = SI_ERR_HANDLE;
-
  if( gptr->magicnum != MAGICNUM )     //  if not a valid ginfo block
   return( SI_ERROR );
 
@@ -124,9 +120,9 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
       }
 
      // for( tpptr = gptr->tplist; tpptr != NULL; tpptr = tpptr->next )
-     for( tpptr = gptr->tplist; tpptr != NULL; tpptr = nextone )
-      {
-       nextone = tpptr->next;                                  //  prevent coredump if we delete the session
+       tpptr = gptr->tplist; 
+       while( tpptr != NULL ) {
+               nextone = tpptr->next;                                  //  allow for a delete in loop
 
        if( tpptr->squeue != NULL && (FD_ISSET( tpptr->fd, &gptr->writefds )) )
         SIsend( gptr, tpptr );              //  send if clear to send
@@ -156,7 +152,7 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
                 SIaddress( uaddr, (void **) &buf, AC_TODOT );
                 status = (*cbptr)( gptr->cbtab[SI_CB_RDATA].cbdata, gptr->rbuf, status, buf );
                 SIcbstat( gptr, status, SI_CB_RDATA );    //  handle status
-               free( buf );
+                               free( buf );
                }                              //  end if call back was defined
              }                                //  end if status was ok
             free( uaddr );
@@ -184,13 +180,14 @@ extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
             }
            }                                                //  end tcp read
         }                    //  end if event on this fd
+
+               tpptr = nextone;
       }                      //  end for each fd in the list
     }                        //  end if not in shutdown
 
 
  if( gptr->flags & GIF_SHUTDOWN )      //  we need to stop for some reason
   {
-   gptr->sierr = SI_ERR_SHUTD;        //  indicate error exit status
    status = SI_ERROR;                //  status should indicate to user to die
    SIshutdown( gptr );            //  clean things up
   }