When using ADNS, don't ask for all network protocols when connecting.
This can lead to confusing "Protocol not supported" errors if the network is down, because UDP sockets are provided. Thanks to jsaak. Closes #1062. Bug: https://github.com/eclipse/mosquitto/issues/1062
This commit is contained in:
parent
d29dac087d
commit
e169f1c7c2
@ -6,6 +6,9 @@ Broker:
|
||||
This is required to work around a problem in libwebsockets that means
|
||||
sockets only listen on IPv6 by default if IPv6 support is compiled in.
|
||||
Closes #1004.
|
||||
- When using ADNS, don't ask for all network protocols when connecting,
|
||||
because this can lead to confusing "Protocol not supported" errors if the
|
||||
network is down. Closes #1062.
|
||||
|
||||
Client:
|
||||
- Always print leading zeros in mosquitto_sub when output format is hex.
|
||||
|
@ -208,21 +208,39 @@ int net__try_connect_step1(struct mosquitto *mosq, const char *host)
|
||||
{
|
||||
int s;
|
||||
void *sevp = NULL;
|
||||
struct addrinfo *hints;
|
||||
|
||||
if(mosq->adns){
|
||||
gai_cancel(mosq->adns);
|
||||
mosquitto__free((struct addrinfo *)mosq->adns->ar_request);
|
||||
mosquitto__free(mosq->adns);
|
||||
}
|
||||
mosq->adns = mosquitto__calloc(1, sizeof(struct gaicb));
|
||||
if(!mosq->adns){
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
|
||||
hints = mosquitto__calloc(1, sizeof(struct addrinfo));
|
||||
if(!hints){
|
||||
mosquitto__free(mosq->adns);
|
||||
mosq->adns = NULL;
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
|
||||
hints->ai_family = AF_UNSPEC;
|
||||
hints->ai_socktype = SOCK_STREAM;
|
||||
|
||||
mosq->adns->ar_name = host;
|
||||
mosq->adns->ar_request = hints;
|
||||
|
||||
s = getaddrinfo_a(GAI_NOWAIT, &mosq->adns, 1, sevp);
|
||||
if(s){
|
||||
errno = s;
|
||||
mosquitto__free(mosq->adns);
|
||||
mosq->adns = NULL;
|
||||
if(mosq->adns){
|
||||
mosquitto__free((struct addrinfo *)mosq->adns->ar_request);
|
||||
mosquitto__free(mosq->adns);
|
||||
mosq->adns = NULL;
|
||||
}
|
||||
return MOSQ_ERR_EAI;
|
||||
}
|
||||
|
||||
@ -278,6 +296,7 @@ int net__try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_sock_t *s
|
||||
freeaddrinfo(mosq->adns->ar_result);
|
||||
mosq->adns->ar_result = NULL;
|
||||
|
||||
mosquitto__free((struct addrinfo *)mosq->adns->ar_request);
|
||||
mosquitto__free(mosq->adns);
|
||||
mosq->adns = NULL;
|
||||
|
||||
|
@ -197,6 +197,13 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
|
||||
context->queued_msgs = NULL;
|
||||
context->last_queued_msg = NULL;
|
||||
}
|
||||
#if defined(WITH_BROKER) && defined(__GLIBC__) && defined(WITH_ADNS)
|
||||
if(context->adns){
|
||||
gai_cancel(context->adns);
|
||||
mosquitto__free((struct addrinfo *)context->adns->ar_request);
|
||||
mosquitto__free(context->adns);
|
||||
}
|
||||
#endif
|
||||
if(do_free){
|
||||
mosquitto__free(context);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user