if (!user_data || !available)
return;
+ vine_disc_h disc_handle;
+ int ret = vine_disc_create(VINE_DISCOVERY_METHOD_DNS_SD, &disc_handle);
+ RET_IF(ret != VINE_ERROR_NONE, "Fail to create a disc");
+
vine_service_h service;
- int ret = _vine_service_create(&service, false);
- RET_IF(ret != VINE_ERROR_NONE, "Fail to create a service");
+ ret = _vine_service_create(&service, false);
+ if (ret != VINE_ERROR_NONE) {
+ vine_disc_destroy(disc_handle);
+ return;
+ }
auto it = attr.find(VINE_DP_PUBSUB_RANK_KEY);
if (it == attr.end()) {
VINE_LOGE("peer doens't have a rank.");
_vine_service_destroy(service);
+ vine_disc_destroy(disc_handle);
return;
}
- ret = _vine_service_set_disc_handle(service, disc);
- RET_IF(ret != VINE_ERROR_NONE, "Fail to set disc_handle");
+ ret = _vine_service_set_disc_handle(service, disc_handle);
+ if (ret != VINE_ERROR_NONE) {
+ VINE_LOGE("Fail to set disc_handle. error(%d)", ret);
+ _vine_service_destroy(service);
+ vine_disc_destroy(disc_handle);
+ return;
+ }
ret = __vine_set_discovered_service(service,
service_type, service_name, host_name, port, attr, iface_name);
if (ret != VINE_ERROR_NONE) {
VINE_LOGE("Fail to set a service. error(%d)", ret);
_vine_service_destroy(service);
+ vine_disc_destroy(disc_handle);
return;
}
dp->increase_init_disc_num();
}
- ret = vine_disc_resolve_ip(disc, service,
+ ret = vine_disc_resolve_ip(disc_handle, service,
_ip_resolved_cb, user_data,
(vine_event_queue_h)static_cast<DataPath *>(user_data)->get_eventfd());
- RET_IF(ret != VINE_ERROR_NONE, "Fail to vine_disc_resolve_ip");
+ if (ret != VINE_ERROR_NONE) {
+ VINE_LOGE("Fail to resolve IP. error(%d)", ret);
+ _vine_service_destroy(service);
+ vine_disc_destroy(disc_handle);
+ return;
+ }
}
static void _service_published_cb(vine_disc_h disc,
break;
}
- VINE_LOGD("peer_ip[%s] found_ip[%s]", peer_ip, found_ip.c_str());
+ VINE_LOGD("peer_ip[%s] found_ip[%s] subnet[%s]", peer_ip, found_ip.c_str(), subnet.c_str());
try {
last = std::stoi(found_ip.substr(pos + 1));
peer_last = std::stoi(peer_ip_str.substr(pos + 1));
static_cast<DataPath *>(user_data)->invoke_opened_cb(VINE_ERROR_NONE);
return;
}
+ VINE_LOGD("invoke opened_cb with an error. sd_state[%d]", sd_state);
static_cast<DataPath *>(user_data)->invoke_opened_cb(VINE_ERROR_OPERATION_FAILED);
}