} else {
if( (gethostname( wbuf, sizeof( wbuf ) )) != 0 ) {
rmr_vlog( RMR_VL_CRIT, "rmr_init: cannot determine localhost name: %s\n", strerror( errno ) );
+ free( proto_port );
return NULL;
}
if( (tok = strchr( wbuf, '.' )) != NULL ) {
ctx->my_ip = get_default_ip( ctx->ip_list ); // and (guess) at what should be the default to put into messages as src
if( ctx->my_ip == NULL ) {
rmr_vlog( RMR_VL_WARN, "rmr_init: default ip address could not be sussed out, using name\n" );
- strcpy( ctx->my_ip, ctx->my_name ); // if we cannot suss it out, use the name rather than a nil pointer
+ ctx->my_ip = strdup( ctx->my_name ); // if we cannot suss it out, use the name rather than a nil pointer
}
}
if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "default ip address: %s\n", ctx->my_ip );
if( (state = nng_listen( ctx->nn_sock, bind_info, NULL, NO_FLAGS )) != 0 ) {
rmr_vlog( RMR_VL_CRIT, "rmr_init: unable to start nng listener for %s: %s\n", bind_info, nng_strerror( state ) );
nng_close( ctx->nn_sock );
+ free( proto_port );
free_ctx( ctx );
return NULL;
}
}
}
- state = 0;
+ state = -1;
errno = 0;
while( chute->mbuf == NULL && ! errno ) {
if( seconds ) {
return NULL; // leave errno as set by sem wait call
}
- mbuf = chute->mbuf;
- mbuf->state = RMR_OK;
+ if( (mbuf = chute->mbuf) != NULL ) {
+ mbuf->state = RMR_OK;
+ }
chute->mbuf = NULL;
return mbuf;