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
Merge "Cmake, change files missing from previous commit"
[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
b5df75f
..
cf06838
100644
(file)
--- a/
src/rmr/si/src/si95/siwait.c
+++ b/
src/rmr/si/src/si95/siwait.c
@@
-49,6
+49,12
@@
#include "sitransport.h"
#include <sys/wait.h>
#include "sitransport.h"
#include <sys/wait.h>
+/*
+ The select timeout is about 300 mu-sec. This is fast enough to add a new
+ outbound connection to the poll list before the other side responds,
+ but slow enough so as not to consume excess CPU when idle.
+*/
+#define SI_SELECT_TIMEOUT 300000
extern int SIwait( struct ginfo_blk *gptr ) {
int fd; // file descriptor for use in this routine
extern int SIwait( struct ginfo_blk *gptr ) {
int fd; // file descriptor for use in this routine
@@
-68,23
+74,21
@@
extern int SIwait( struct ginfo_blk *gptr ) {
gptr->sierr = SI_ERR_SHUTD;
if( gptr->flags & GIF_SHUTDOWN ) { // cannot do if we should shutdown
gptr->sierr = SI_ERR_SHUTD;
if( gptr->flags & GIF_SHUTDOWN ) { // cannot do if we should shutdown
- fprintf( stderr, ">>> wait: shutdown on entry????\n" );
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; // so just get out
}
gptr->sierr = SI_ERR_HANDLE;
if( gptr->magicnum != MAGICNUM ) { // if not a valid ginfo block
-
fprintf( stderr, ">>> wait: bad magic on entry????
\n" );
+
rmr_vlog( RMR_VL_CRIT, "SI95: wait: bad global info struct magic number is wrong
\n" );
return SI_ERROR;
}
return SI_ERROR;
}
- timeout.tv_sec = 0;
- timeout.tv_usec = 500000; // pop every 500ms to ensure we pick up new outbound connections in list
-
- do { // main wait/process loop
+ do { // spin until a callback says to stop (likely never)
+ timeout.tv_sec = 0; // must be reset on every call!
+ timeout.tv_usec = SI_SELECT_TIMEOUT;
- SIbldpoll( gptr ); //
build the fdlist for poll
+ SIbldpoll( gptr ); //
poll list is trashed on each pop; must rebuild
pstat = select( gptr->fdcount, &gptr->readfds, &gptr->writefds, &gptr->execpfds, &timeout );
if( (pstat < 0 && errno != EINTR) ) {
pstat = select( gptr->fdcount, &gptr->readfds, &gptr->writefds, &gptr->execpfds, &timeout );
if( (pstat < 0 && errno != EINTR) ) {