Skip to content

Commit

Permalink
suppress recv error message on normal quit
Browse files Browse the repository at this point in the history
  • Loading branch information
fogleman committed Jan 2, 2014
1 parent 2e38446 commit 052818e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/client.c
Expand Up @@ -17,6 +17,7 @@
#define BUFFER_SIZE 4096

static int client_enabled = 0;
static int running = 0;
static int sd = 0;
static char recv_buffer[QUEUE_SIZE] = {0};
static thrd_t recv_thread;
Expand Down Expand Up @@ -150,8 +151,13 @@ int recv_worker(void *arg) {
while (1) {
char data[BUFFER_SIZE] = {0};
if (recv(sd, data, BUFFER_SIZE - 1, 0) <= 0) {
perror("recv");
exit(1);
if (running) {
perror("recv");
exit(1);
}
else {
break;
}
}
while (1) {
int done = 0;
Expand Down Expand Up @@ -198,6 +204,7 @@ void client_start() {
if (!client_enabled) {
return;
}
running = 1;
mtx_init(&mutex, mtx_plain);
if (thrd_create(&recv_thread, recv_worker, NULL) != thrd_success) {
perror("thrd_create");
Expand All @@ -209,6 +216,7 @@ void client_stop() {
if (!client_enabled) {
return;
}
running = 0;
close(sd);
// if (thrd_join(recv_thread, NULL) != thrd_success) {
// perror("thrd_join");
Expand Down

0 comments on commit 052818e

Please sign in to comment.