Skip to content

Commit

Permalink
server: avoid overflowing the failure counter
Browse files Browse the repository at this point in the history
  • Loading branch information
grobian committed Dec 10, 2016
1 parent cf6c4a3 commit 5b1e04d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
[Pull #127](https://github.com/grobian/carbon-c-relay/issues/127),
[Pull #87](https://github.com/grobian/carbon-c-relay/issues/87).

### Bugfixes

* **server** connection errors are no longer endlessly repeated

# 2.3 (2016-11-07)

### Bugfixes
Expand Down
3 changes: 3 additions & 0 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ server_queuereader(void *d)
if (__sync_bool_compare_and_swap(&(self->keep_running), 0, 0))
break;
usleep((200 + (rand() % 100)) * 1000); /* 200ms - 300ms */
/* avoid overflowing */
if (__sync_add_and_fetch(&(self->failure), 0) > FAIL_WAIT_TIME)
__sync_sub_and_fetch(&(self->failure), 1);
}

/* at this point we've got work to do, if we're instructed to
Expand Down

0 comments on commit 5b1e04d

Please sign in to comment.