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
More changes for scan corrections and unit test coverage
[ric-plt/lib/rmr.git]
/
src
/
rmr
/
common
/
src
/
rtc_static.c
diff --git
a/src/rmr/common/src/rtc_static.c
b/src/rmr/common/src/rtc_static.c
index
c1bad15
..
15fe567
100644
(file)
--- a/
src/rmr/common/src/rtc_static.c
+++ b/
src/rmr/common/src/rtc_static.c
@@
-76,15
+76,18
@@
static void* rtc_file( void* vctx ) {
ctx->flags |= CFL_NO_RTACK; // no attempt to ack when reading from a file
while( 1 ) {
if( vfd >= 0 ) {
ctx->flags |= CFL_NO_RTACK; // no attempt to ack when reading from a file
while( 1 ) {
if( vfd >= 0 ) {
-
wbuf[0] = 0
;
- lseek( vfd, 0, 0 );
-
read( vfd, wbuf, 10
);
- vlevel = atoi( wbuf );
+
memset( wbuf, 0, sizeof( char ) * 11 )
;
+ if( lseek( vfd, 0, SEEK_SET ) == 0 && read( vfd, wbuf, 10 ) > 0 ) {
+
vlevel = atoi( wbuf
);
+ }
}
read_static_rt( ctx, vlevel ); // seed the route table if one provided
if( ctx->shutdown != 0 ) { // allow for graceful termination and unit testing
}
read_static_rt( ctx, vlevel ); // seed the route table if one provided
if( ctx->shutdown != 0 ) { // allow for graceful termination and unit testing
+ if( vfd >= 0 ) {
+ close( vfd );
+ }
return NULL;
}
sleep( 60 );
return NULL;
}
sleep( 60 );
@@
-97,9
+100,10
@@
static int refresh_vlevel( int vfd ) {
if( vfd >= 0 ) { // if file is open, read current value
rbuf[0] = 0;
if( vfd >= 0 ) { // if file is open, read current value
rbuf[0] = 0;
- lseek( vfd, 0, 0 );
- read( vfd, rbuf, 10 );
- vlevel = atoi( rbuf );
+ memset( rbuf, 0, sizeof( char ) * 11 );
+ if( lseek( vfd, 0, SEEK_SET ) == 0 && read( vfd, rbuf, 10 ) > 0 ) {
+ vlevel = atoi( rbuf );
+ }
}
return vlevel;
}
return vlevel;
@@
-270,6
+274,11
@@
static void* rtc( void* vctx ) {
return NULL;
}
return NULL;
}
+ if( (ctx->ephash = rmr_sym_alloc( RT_SIZE )) == NULL ) { // master hash table for endpoints (each rt will reference this)
+ rmr_vlog( RMR_VL_CRIT, "rmr_rtc: internal mishap: unable to allocate an endpoint hash table\n" );
+ return NULL;
+ }
+
if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
vfd = open( eptr, O_RDONLY );
vlevel = refresh_vlevel( vfd );
if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
vfd = open( eptr, O_RDONLY );
vlevel = refresh_vlevel( vfd );