you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
char* port; // a port number we listen/connect to
char* fport; // pointer to the real buffer to free
size_t buf_size; // nng needs var pointer not just size?
- char* nextr; // pointer at next record in the message
+ char* nextr; // pointer at next record in the message
char* curr; // current record
int i;
long blabber = 0; // time of last blabber so we don't flood if rtg goes bad
int state; // processing state of some nng function
char* tokens[128];
char wbuf[128];
- char* pbuf;
+ char* pbuf = NULL;
int pbuf_size = 0; // number allocated in pbuf
int ntoks;
int raw_interface = 1; // rtg is using raw NNG/Nano not RMr to send updates
}
if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
- vfd = open( eptr, O_RDONLY );
+ vfd = open( eptr, O_RDONLY );
if( vfd >= 0 ) {
wbuf[0] = 0;
lseek( vfd, 0, 0 );
ntoks = uta_tokenise( port, tokens, 120, ':' ); // assume tcp:port, but it could be port or old style host:port
switch( ntoks ) {
- case 1:
+ case 1:
port = tokens[0]; // just the port
break;
if( pbuf ) {
free( pbuf );
}
- pbuf = (char *) malloc( sizeof( char ) * mlen *2 );
- pbuf_size = mlen * 2;
+ if( mlen < 512 ) {
+ pbuf_size = 512;
+ } else {
+ pbuf_size = mlen * 2;
+ }
+ pbuf = (char *) malloc( sizeof( char ) * pbuf_size );
}
memcpy( pbuf, payload, mlen );
pbuf[mlen] = 0; // don't depend on sender making this a legit string
curr = pbuf;
while( curr ) { // loop over each record in the buffer
nextr = strchr( curr, '\n' ); // allow multiple newline records, find end of current and mark
-
+
if( nextr ) {
*(nextr++) = 0;
}
-
+
if( vlevel > 1 ) {
fprintf( stderr, "[DBUG] rmr_rtc: processing (%s)\n", curr );
}
parse_rt_rec( ctx, curr, vlevel ); // parse record and add to in progress table
-
+
curr = nextr;
}
-
+
if( ctx->shutdown ) { // mostly for testing, but allows user app to close us down if rmr_*() function sets this
break;
}