Code Review
/
ric-plt
/
lib
/
rmr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixing minor exception checks
[ric-plt/lib/rmr.git]
/
src
/
rmr
/
si
/
src
/
si95
/
siwait.c
diff --git
a/src/rmr/si/src/si95/siwait.c
b/src/rmr/si/src/si95/siwait.c
index
75de117
..
291b8aa
100644
(file)
--- a/
src/rmr/si/src/si95/siwait.c
+++ b/
src/rmr/si/src/si95/siwait.c
@@
-69,18
+69,19
@@
extern int SIwait( struct ginfo_blk *gptr ) {
char *buf;
char *ibuf;
char *buf;
char *ibuf;
- ibuf = (char *) malloc( 2048 );
-
- gptr->sierr = SI_ERR_SHUTD;
+ if( ( ibuf = (char *) malloc( 2048 ) ) == NULL ) {
+ rmr_vlog( RMR_VL_WARN, "ibuf malloc fail\n" );
+ return SI_ERROR;
+ }
if( gptr->flags & GIF_SHUTDOWN ) { // cannot do if we should shutdown
if( gptr->flags & GIF_SHUTDOWN ) { // cannot do if we should shutdown
+ free( ibuf );
return SI_ERROR; // so just get out
}
return SI_ERROR; // so just get out
}
- gptr->sierr = SI_ERR_HANDLE;
-
if( gptr->magicnum != MAGICNUM ) { // if not a valid ginfo block
if( gptr->magicnum != MAGICNUM ) { // if not a valid ginfo block
- fprintf( stderr, "[CRI] SI95: wait: bad global info struct magic number is wrong\n" );
+ rmr_vlog( RMR_VL_CRIT, "SI95: wait: bad global info struct magic number is wrong\n" );
+ free( ibuf );
return SI_ERROR;
}
return SI_ERROR;
}
@@
-97,7
+98,8
@@
extern int SIwait( struct ginfo_blk *gptr ) {
}
if( pstat > 0 && (! (gptr->flags & GIF_SHUTDOWN)) ) {
}
if( pstat > 0 && (! (gptr->flags & GIF_SHUTDOWN)) ) {
- for( tpptr = gptr->tplist; tpptr != NULL; tpptr = nextone ) {
+ tpptr = gptr->tplist;
+ while( tpptr != NULL ) {
nextone = tpptr->next; // prevent issues if we delete the block during loop
if( tpptr->fd >= 0 ) {
nextone = tpptr->next; // prevent issues if we delete the block during loop
if( tpptr->fd >= 0 ) {
@@
-127,22
+129,22
@@
extern int SIwait( struct ginfo_blk *gptr ) {
status = (*cbptr)( gptr->cbtab[SI_CB_DISC].cbdata, tpptr->fd );
SIcbstat( gptr, status, SI_CB_DISC ); // handle status
}
status = (*cbptr)( gptr->cbtab[SI_CB_DISC].cbdata, tpptr->fd );
SIcbstat( gptr, status, SI_CB_DISC ); // handle status
}
- SIterm( gptr, tpptr );
+ SIterm( gptr, tpptr );
// close FD and mark block for deletion
}
}
}
}
} // if still good fd
}
}
}
}
} // if still good fd
+
+ tpptr = nextone;
}
}
} while( gptr->tplist != NULL && !(gptr->flags & GIF_SHUTDOWN) );
free( ibuf );
if( gptr->tplist == NULL ) // indicate all fds closed
}
}
} while( gptr->tplist != NULL && !(gptr->flags & GIF_SHUTDOWN) );
free( ibuf );
if( gptr->tplist == NULL ) // indicate all fds closed
- gptr->sierr = SI_ERR_NOFDS;
if( gptr->flags & GIF_SHUTDOWN ) { // we need to stop for some reason
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
} else {
status = SI_ERROR; // status should indicate to user to die
SIshutdown( gptr ); // clean things up
} else {