Skip to content
Snippets Groups Projects
Commit 9a4790ac authored by Timothe Jost's avatar Timothe Jost
Browse files

test fixing segmentation fault

parent ccf8bd98
No related branches found
No related tags found
No related merge requests found
...@@ -212,30 +212,29 @@ void *readUdp(void *arg) ...@@ -212,30 +212,29 @@ void *readUdp(void *arg)
timeout.tv_sec = 2; // 5 seconds timeout timeout.tv_sec = 2; // 5 seconds timeout
timeout.tv_usec = 0; timeout.tv_usec = 0;
if (setsockopt(udp_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) // if (setsockopt(udp_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
{ // {
perror("setsockopt failed"); // perror("setsockopt failed");
SHOULD_EXIT = 1; // SHOULD_EXIT = 1;
return NULL; // return NULL;
} // }
for (;;) for (;;)
{ {
int bytes_read = (int)recvfrom(udp_sock, buffer, MAX_BUFFER_SIZE, 0, &recv_addr, &len); int bytes_read = (int)recvfrom(udp_sock, buffer, MAX_BUFFER_SIZE, 0, &recv_addr, &len);
if (bytes_read > 0 && !isOwnIp(&recv_addr)) if (bytes_read > 0 && !isOwnIp(&recv_addr))
{ {
printf("Controller message recieved %s\n", bytes_read); printf("Controller message recieved %d\n", bytes_read);
processSmcp1Request(buffer, &recv_addr, bytes_read); processSmcp1Request(buffer, &recv_addr, bytes_read);
} }
else if (bytes_read < 0) else if (bytes_read < 0)
{ {
if (errno == EWOULDBLOCK || errno == EAGAIN) // if (errno == EWOULDBLOCK || errno == EAGAIN)
{ // {
// printf("recvfrom timeout, no data received.\n"); // // printf("recvfrom timeout, no data received.\n");
} // }
else // else
{ // {
perror("recvfrom failed"); perror("recvfrom failed");
if (PROXY_INIT_COMPLETE) if (PROXY_INIT_COMPLETE)
{ {
...@@ -243,7 +242,7 @@ void *readUdp(void *arg) ...@@ -243,7 +242,7 @@ void *readUdp(void *arg)
SHOULD_EXIT = 1; SHOULD_EXIT = 1;
break; break;
} }
} // }
} }
if (SHOULD_EXIT && PROXY_INIT_COMPLETE) if (SHOULD_EXIT && PROXY_INIT_COMPLETE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment