|
|
|
@ -182,7 +182,7 @@ int bridge__connect_step1(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_NOTICE, "Connecting bridge %s (%s:%d)", context->bridge->name, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port);
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_NOTICE, "Connecting bridge (step 1) %s (%s:%d)", context->bridge->name, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port);
|
|
|
|
|
rc = net__try_connect_step1(context, context->bridge->addresses[context->bridge->cur_address].address);
|
|
|
|
|
if(rc > 0 ){
|
|
|
|
|
if(rc == MOSQ_ERR_TLS){
|
|
|
|
@ -207,9 +207,9 @@ int bridge__connect_step2(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
|
|
|
|
|
if(!context || !context->bridge) return MOSQ_ERR_INVAL;
|
|
|
|
|
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_NOTICE, "Connecting bridge %s (%s:%d)", context->bridge->name, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port);
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_NOTICE, "Connecting bridge (step 2) %s (%s:%d)", context->bridge->name, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port);
|
|
|
|
|
rc = net__try_connect_step2(context, context->bridge->addresses[context->bridge->cur_address].port, &context->sock);
|
|
|
|
|
if(rc > 0 ){
|
|
|
|
|
if(rc > 0){
|
|
|
|
|
if(rc == MOSQ_ERR_TLS){
|
|
|
|
|
net__socket_close(db, context);
|
|
|
|
|
return rc; /* Error already printed */
|
|
|
|
@ -222,8 +222,21 @@ int bridge__connect_step2(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HASH_ADD(hh_sock, db->contexts_by_sock, sock, sizeof(context->sock), context);
|
|
|
|
|
|
|
|
|
|
if(rc == MOSQ_ERR_CONN_PENDING){
|
|
|
|
|
context->state = mosq_cs_connect_pending;
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int bridge__connect_step3(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = net__socket_connect_step3(context, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port, NULL, false);
|
|
|
|
|
if(rc > 0 ){
|
|
|
|
|
if(rc > 0){
|
|
|
|
|
if(rc == MOSQ_ERR_TLS){
|
|
|
|
|
net__socket_close(db, context);
|
|
|
|
|
return rc; /* Error already printed */
|
|
|
|
@ -236,11 +249,6 @@ int bridge__connect_step2(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HASH_ADD(hh_sock, db->contexts_by_sock, sock, sizeof(context->sock), context);
|
|
|
|
|
|
|
|
|
|
if(rc == MOSQ_ERR_CONN_PENDING){
|
|
|
|
|
context->state = mosq_cs_connect_pending;
|
|
|
|
|
}
|
|
|
|
|
rc = send__connect(context, context->keepalive, context->clean_session);
|
|
|
|
|
if(rc == MOSQ_ERR_SUCCESS){
|
|
|
|
|
return MOSQ_ERR_SUCCESS;
|
|
|
|
|