(ws) initialize maxWaitBetweenReconnectionRetries to a non zero value ; a zero value was causing spurious reconnections attempts
This commit is contained in:
parent
1410797d6f
commit
def0243d6d
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [11.1.2] - 2021-03-22
|
||||||
|
|
||||||
|
(ws) initialize maxWaitBetweenReconnectionRetries to a non zero value ; a zero value was causing spurious reconnections attempts
|
||||||
|
|
||||||
## [11.1.1] - 2021-03-20
|
## [11.1.1] - 2021-03-20
|
||||||
|
|
||||||
(cmake) Library can be built as a static or a dynamic library, controlled with BUILD_SHARED_LIBS. Default to static library
|
(cmake) Library can be built as a static or a dynamic library, controlled with BUILD_SHARED_LIBS. Default to static library
|
||||||
|
@ -132,48 +132,61 @@ namespace ix
|
|||||||
#if defined(_WIN32) && defined(__GNUC__)
|
#if defined(_WIN32) && defined(__GNUC__)
|
||||||
const char* inet_ntop(int af, const void* a0, char* s, socklen_t l)
|
const char* inet_ntop(int af, const void* a0, char* s, socklen_t l)
|
||||||
{
|
{
|
||||||
const unsigned char *a = (const unsigned char*) a0;
|
const unsigned char* a = (const unsigned char*) a0;
|
||||||
int i, j, max, best;
|
int i, j, max, best;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
|
||||||
switch (af) {
|
switch (af)
|
||||||
case AF_INET:
|
{
|
||||||
if (snprintf(s, l, "%d.%d.%d.%d", a[0],a[1],a[2],a[3]) < l)
|
case AF_INET:
|
||||||
return s;
|
if (snprintf(s, l, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]) < l) return s;
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
if (memcmp(a, "\0\0\0\0\0\0\0\0\0\0\377\377", 12))
|
if (memcmp(a, "\0\0\0\0\0\0\0\0\0\0\377\377", 12))
|
||||||
snprintf(buf, sizeof buf,
|
snprintf(buf,
|
||||||
"%x:%x:%x:%x:%x:%x:%x:%x",
|
sizeof buf,
|
||||||
256*a[0]+a[1],256*a[2]+a[3],
|
"%x:%x:%x:%x:%x:%x:%x:%x",
|
||||||
256*a[4]+a[5],256*a[6]+a[7],
|
256 * a[0] + a[1],
|
||||||
256*a[8]+a[9],256*a[10]+a[11],
|
256 * a[2] + a[3],
|
||||||
256*a[12]+a[13],256*a[14]+a[15]);
|
256 * a[4] + a[5],
|
||||||
else
|
256 * a[6] + a[7],
|
||||||
snprintf(buf, sizeof buf,
|
256 * a[8] + a[9],
|
||||||
"%x:%x:%x:%x:%x:%x:%d.%d.%d.%d",
|
256 * a[10] + a[11],
|
||||||
256*a[0]+a[1],256*a[2]+a[3],
|
256 * a[12] + a[13],
|
||||||
256*a[4]+a[5],256*a[6]+a[7],
|
256 * a[14] + a[15]);
|
||||||
256*a[8]+a[9],256*a[10]+a[11],
|
else
|
||||||
a[12],a[13],a[14],a[15]);
|
snprintf(buf,
|
||||||
/* Replace longest /(^0|:)[:0]{2,}/ with "::" */
|
sizeof buf,
|
||||||
for (i=best=0, max=2; buf[i]; i++) {
|
"%x:%x:%x:%x:%x:%x:%d.%d.%d.%d",
|
||||||
if (i && buf[i] != ':') continue;
|
256 * a[0] + a[1],
|
||||||
j = strspn(buf+i, ":0");
|
256 * a[2] + a[3],
|
||||||
if (j>max) best=i, max=j;
|
256 * a[4] + a[5],
|
||||||
}
|
256 * a[6] + a[7],
|
||||||
if (max>3) {
|
256 * a[8] + a[9],
|
||||||
buf[best] = buf[best+1] = ':';
|
256 * a[10] + a[11],
|
||||||
memmove(buf+best+2, buf+best+max, i-best-max+1);
|
a[12],
|
||||||
}
|
a[13],
|
||||||
if (strlen(buf) < l) {
|
a[14],
|
||||||
strcpy(s, buf);
|
a[15]);
|
||||||
return s;
|
/* Replace longest /(^0|:)[:0]{2,}/ with "::" */
|
||||||
}
|
for (i = best = 0, max = 2; buf[i]; i++)
|
||||||
break;
|
{
|
||||||
default:
|
if (i && buf[i] != ':') continue;
|
||||||
errno = EAFNOSUPPORT;
|
j = strspn(buf + i, ":0");
|
||||||
return 0;
|
if (j > max) best = i, max = j;
|
||||||
|
}
|
||||||
|
if (max > 3)
|
||||||
|
{
|
||||||
|
buf[best] = buf[best + 1] = ':';
|
||||||
|
memmove(buf + best + 2, buf + best + max, i - best - max + 1);
|
||||||
|
}
|
||||||
|
if (strlen(buf) < l)
|
||||||
|
{
|
||||||
|
strcpy(s, buf);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: errno = EAFNOSUPPORT; return 0;
|
||||||
}
|
}
|
||||||
errno = ENOSPC;
|
errno = ENOSPC;
|
||||||
return 0;
|
return 0;
|
||||||
@ -181,67 +194,77 @@ const char* inet_ntop(int af, const void* a0, char* s, socklen_t l)
|
|||||||
|
|
||||||
static int hexval(unsigned c)
|
static int hexval(unsigned c)
|
||||||
{
|
{
|
||||||
if (c-'0'<10) return c-'0';
|
if (c - '0' < 10) return c - '0';
|
||||||
c |= 32;
|
c |= 32;
|
||||||
if (c-'a'<6) return c-'a'+10;
|
if (c - 'a' < 6) return c - 'a' + 10;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inet_pton(int af, const char* s, void* a0)
|
int inet_pton(int af, const char* s, void* a0)
|
||||||
{
|
{
|
||||||
uint16_t ip[8];
|
uint16_t ip[8];
|
||||||
unsigned char *a = (unsigned char*) a0;
|
unsigned char* a = (unsigned char*) a0;
|
||||||
int i, j, v, d, brk=-1, need_v4=0;
|
int i, j, v, d, brk = -1, need_v4 = 0;
|
||||||
|
|
||||||
if (af==AF_INET) {
|
if (af == AF_INET)
|
||||||
for (i=0; i<4; i++) {
|
{
|
||||||
for (v=j=0; j<3 && isdigit(s[j]); j++)
|
for (i = 0; i < 4; i++)
|
||||||
v = 10*v + s[j]-'0';
|
{
|
||||||
if (j==0 || (j>1 && s[0]=='0') || v>255) return 0;
|
for (v = j = 0; j < 3 && isdigit(s[j]); j++)
|
||||||
a[i] = v;
|
v = 10 * v + s[j] - '0';
|
||||||
if (s[j]==0 && i==3) return 1;
|
if (j == 0 || (j > 1 && s[0] == '0') || v > 255) return 0;
|
||||||
if (s[j]!='.') return 0;
|
a[i] = v;
|
||||||
s += j+1;
|
if (s[j] == 0 && i == 3) return 1;
|
||||||
}
|
if (s[j] != '.') return 0;
|
||||||
return 0;
|
s += j + 1;
|
||||||
} else if (af!=AF_INET6) {
|
}
|
||||||
errno = EAFNOSUPPORT;
|
return 0;
|
||||||
return -1;
|
}
|
||||||
}
|
else if (af != AF_INET6)
|
||||||
|
{
|
||||||
|
errno = EAFNOSUPPORT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (*s==':' && *++s!=':') return 0;
|
if (*s == ':' && *++s != ':') return 0;
|
||||||
|
|
||||||
for (i=0; ; i++) {
|
for (i = 0;; i++)
|
||||||
if (s[0]==':' && brk<0) {
|
{
|
||||||
brk=i;
|
if (s[0] == ':' && brk < 0)
|
||||||
ip[i&7]=0;
|
{
|
||||||
if (!*++s) break;
|
brk = i;
|
||||||
if (i==7) return 0;
|
ip[i & 7] = 0;
|
||||||
continue;
|
if (!*++s) break;
|
||||||
}
|
if (i == 7) return 0;
|
||||||
for (v=j=0; j<4 && (d=hexval(s[j]))>=0; j++)
|
continue;
|
||||||
v=16*v+d;
|
}
|
||||||
if (j==0) return 0;
|
for (v = j = 0; j < 4 && (d = hexval(s[j])) >= 0; j++)
|
||||||
ip[i&7] = v;
|
v = 16 * v + d;
|
||||||
if (!s[j] && (brk>=0 || i==7)) break;
|
if (j == 0) return 0;
|
||||||
if (i==7) return 0;
|
ip[i & 7] = v;
|
||||||
if (s[j]!=':') {
|
if (!s[j] && (brk >= 0 || i == 7)) break;
|
||||||
if (s[j]!='.' || (i<6 && brk<0)) return 0;
|
if (i == 7) return 0;
|
||||||
need_v4=1;
|
if (s[j] != ':')
|
||||||
i++;
|
{
|
||||||
break;
|
if (s[j] != '.' || (i < 6 && brk < 0)) return 0;
|
||||||
}
|
need_v4 = 1;
|
||||||
s += j+1;
|
i++;
|
||||||
}
|
break;
|
||||||
if (brk>=0) {
|
}
|
||||||
memmove(ip+brk+7-i, ip+brk, 2*(i+1-brk));
|
s += j + 1;
|
||||||
for (j=0; j<7-i; j++) ip[brk+j] = 0;
|
}
|
||||||
}
|
if (brk >= 0)
|
||||||
for (j=0; j<8; j++) {
|
{
|
||||||
*a++ = ip[j]>>8;
|
memmove(ip + brk + 7 - i, ip + brk, 2 * (i + 1 - brk));
|
||||||
*a++ = ip[j];
|
for (j = 0; j < 7 - i; j++)
|
||||||
}
|
ip[brk + j] = 0;
|
||||||
if (need_v4 && inet_pton(AF_INET, (const char *)s, a-4) <= 0) return 0;
|
}
|
||||||
return 1;
|
for (j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
*a++ = ip[j] >> 8;
|
||||||
|
*a++ = ip[j];
|
||||||
|
}
|
||||||
|
if (need_v4 && inet_pton(AF_INET, (const char*) s, a - 4) <= 0) return 0;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif // defined(_WIN32) && defined(__GNUC__)
|
#endif // defined(_WIN32) && defined(__GNUC__)
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "11.1.1"
|
#define IX_WEBSOCKET_VERSION "11.1.2"
|
||||||
|
@ -2487,7 +2487,7 @@ int main(int argc, char** argv)
|
|||||||
int delayMs = -1;
|
int delayMs = -1;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
int msgCount = 1000 * 1000;
|
int msgCount = 1000 * 1000;
|
||||||
uint32_t maxWaitBetweenReconnectionRetries;
|
uint32_t maxWaitBetweenReconnectionRetries = 10 * 1000; // 10 seconds
|
||||||
int pingIntervalSecs = 30;
|
int pingIntervalSecs = 30;
|
||||||
int runCount = 1;
|
int runCount = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user