Fix potential race in route table load
[ric-plt/lib/rmr.git] / src / rmr / common / src / rtc_static.c
index e92e53d..2deef8e 100644 (file)
@@ -270,6 +270,11 @@ static void* rtc( void* vctx ) {
                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 );
@@ -279,7 +284,7 @@ static void* rtc( void* vctx ) {
                rt_req_freq = atoi( eptr );
                if( rt_req_freq < 1 || rt_req_freq > 300 ) {
                        rt_req_freq = DEF_RTREQ_FREQ;
-                       rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%s) out of range (1-300), using default", DEF_RTREQ_FREQ );
+                       rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%d) out of range (1-300), using default", DEF_RTREQ_FREQ );
                }
        }
        rmr_vlog( RMR_VL_INFO, "rmr_rtc: RT request frequency set to: %d seconds", rt_req_freq );