Compare commits
1 Commits
revert-370
...
bsergean-p
Author | SHA1 | Date | |
---|---|---|---|
5698ed879f |
@ -2,7 +2,9 @@
|
||||
|
||||
IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use and support everything you'll likely need for websocket dev (SSL, deflate compression, compiles on most platforms, etc...). HTTP client and server code is also available, but it hasn't received as much testing.
|
||||
|
||||
It is been used on big mobile video game titles sending and receiving tons of messages since 2017 (iOS and Android). It was tested on macOS, iOS, Linux, Android, Windows and FreeBSD. Two important design goals are simplicity and correctness.
|
||||
It is been used on big mobile video game titles sending and receiving tons of messages since 2017 (iOS and Android). It was tested on macOS, iOS, Linux, Android, Windows and FreeBSD. Note that the MinGW compiler is not supported at this point. Two important design goals are simplicity and correctness.
|
||||
|
||||
A bad security bug affecting users compiling with SSL enabled and OpenSSL as the backend was just fixed in newly released version 11.0.0. Please upgrade ! (more details in the [https://github.com/machinezone/IXWebSocket/pull/250](PR).
|
||||
|
||||
```cpp
|
||||
/*
|
||||
|
@ -14,27 +14,14 @@ namespace ix
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
uint32_t minWaitBetweenReconnectionRetries)
|
||||
{
|
||||
// It's easy with a power function to go beyond 2^32, and then
|
||||
// have unexpected results, so prepare for that
|
||||
const uint32_t maxRetryCountWithoutOverflow = 26;
|
||||
|
||||
uint32_t waitTime = 0;
|
||||
if (retryCount < maxRetryCountWithoutOverflow)
|
||||
{
|
||||
waitTime = std::pow(2, retryCount) * 100;
|
||||
}
|
||||
uint32_t waitTime = (retryCount < 26) ? (std::pow(2, retryCount) * 100) : 0;
|
||||
|
||||
if (waitTime < minWaitBetweenReconnectionRetries)
|
||||
{
|
||||
waitTime = minWaitBetweenReconnectionRetries;
|
||||
}
|
||||
|
||||
if (waitTime > maxWaitBetweenReconnectionRetries)
|
||||
{
|
||||
waitTime = maxWaitBetweenReconnectionRetries;
|
||||
}
|
||||
|
||||
if (retryCount >= maxRetryCountWithoutOverflow)
|
||||
if (waitTime > maxWaitBetweenReconnectionRetries || waitTime == 0)
|
||||
{
|
||||
waitTime = maxWaitBetweenReconnectionRetries;
|
||||
}
|
||||
|
@ -339,12 +339,12 @@ namespace ix
|
||||
{
|
||||
int cn_pos = X509_NAME_get_index_by_NID(
|
||||
X509_get_subject_name((X509*) server_cert), NID_commonName, -1);
|
||||
if (cn_pos >= 0)
|
||||
if (cn_pos)
|
||||
{
|
||||
X509_NAME_ENTRY* cn_entry =
|
||||
X509_NAME_get_entry(X509_get_subject_name((X509*) server_cert), cn_pos);
|
||||
|
||||
if (cn_entry != nullptr)
|
||||
if (cn_entry)
|
||||
{
|
||||
ASN1_STRING* cn_asn1 = X509_NAME_ENTRY_get_data(cn_entry);
|
||||
char* cn = (char*) ASN1_STRING_data(cn_asn1);
|
||||
|
@ -23,7 +23,6 @@ set (TEST_TARGET_NAMES
|
||||
IXWebSocketSubProtocolTest
|
||||
# IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws
|
||||
IXStrCaseCompareTest
|
||||
IXExponentialBackoffTest
|
||||
)
|
||||
|
||||
# Some unittest don't work on windows yet
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* IXExponentialBackoffTest.cpp
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2022 Machine Zone. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "IXTest.h"
|
||||
#include "catch.hpp"
|
||||
#include <iostream>
|
||||
#include <ixwebsocket/IXExponentialBackoff.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace ix;
|
||||
|
||||
namespace ix
|
||||
{
|
||||
TEST_CASE("exponential_backoff", "[exponential_backoff]")
|
||||
{
|
||||
SECTION("1")
|
||||
{
|
||||
// First parameter is retrycount
|
||||
REQUIRE(calculateRetryWaitMilliseconds(0, 10000, 100) == 100);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(1, 10000, 100) == 200);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(2, 10000, 100) == 400);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(3, 10000, 100) == 800);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(4, 10000, 100) == 1600);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(5, 10000, 100) == 3200);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(6, 10000, 100) == 6400);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(20, 10000, 100) == 10000);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(25, 10000, 100) == 10000);
|
||||
|
||||
// Things get special after 26 retries
|
||||
REQUIRE(calculateRetryWaitMilliseconds(26, 10000, 100) == 10000);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(27, 10000, 100) == 10000);
|
||||
REQUIRE(calculateRetryWaitMilliseconds(27, 10000, 100) == 10000);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ix
|
Reference in New Issue
Block a user