Browse Source

Null terminate ./marketmaker events output

jl777
jl777 7 years ago
parent
commit
00bc5befb1
  1. 10
      iguana/exchanges/mm.c

10
iguana/exchanges/mm.c

@ -185,16 +185,22 @@ int main(int argc, const char * argv[])
} }
else if ( argv[1] != 0 && strcmp(argv[1],"events") == 0 ) else if ( argv[1] != 0 && strcmp(argv[1],"events") == 0 )
{ {
int32_t len; void *ptr; int32_t len,bufsize = 1000000; void *ptr; char *buf;
if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 ) if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 )
{ {
if ( nn_connect(IPC_ENDPOINT,"ws://127.0.0.1:5555") >= 0 ) if ( nn_connect(IPC_ENDPOINT,"ws://127.0.0.1:5555") >= 0 )
{ {
buf = calloc(1,bufsize);
while ( 1 ) while ( 1 )
{ {
if ( (len= nn_recv(IPC_ENDPOINT,&ptr,NN_MSG,0)) > 0 ) if ( (len= nn_recv(IPC_ENDPOINT,&ptr,NN_MSG,0)) > 0 )
{ {
printf("%s\n",(char *)ptr); if ( len < bufsize )
{
memcpy(buf,ptr,len);
buf[len] = 0;
printf("%s\n",(char *)buf);
}
nn_freemsg(ptr); nn_freemsg(ptr);
} }
} }

Loading…
Cancel
Save