void vine_disc_destroy(vine_disc_h disc)
{
+ vine_disc_s *disc_handle = (vine_disc_s *)disc;
+ if (disc_handle && disc_handle->plugin_fn &&
+ disc_handle->plugin_fn->deinit && disc_handle->plugin_handle)
+ disc_handle->plugin_fn->deinit(disc_handle->plugin_handle);
free(disc);
}
vine_disc_s *disc_handle = (vine_disc_s *)disc;
void *plugin_handle = NULL;
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
if (disc_handle->plugin_fn->init == NULL) {
VINE_LOGE("No init() defined");
return VINE_ERROR_OPERATION_FAILED;
if (disc_handle->plugin_fn->publish == NULL) {
VINE_LOGE("No publish() defined");
+ disc_handle->plugin_fn->deinit(plugin_handle);
+ disc_handle->plugin_handle = NULL;
return VINE_ERROR_OPERATION_FAILED;
}
if (error != VINE_DISC_ERROR_NONE) {
VINE_LOGE("Fail to publish %d", error);
disc_handle->plugin_fn->deinit(plugin_handle);
+ disc_handle->plugin_handle = NULL;
return __convert_disc_error_to_vine_error(error);
}
vine_disc_error error = VINE_DISC_ERROR_NONE;
vine_disc_s *disc_handle = (vine_disc_s *)disc;
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
if (disc_handle->plugin_fn->init == NULL) {
VINE_LOGE("No init() defined");
return VINE_ERROR_OPERATION_FAILED;
vine_disc_s *disc_handle = (vine_disc_s *)disc;
void *plugin_handle = NULL;
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
if (disc_handle->plugin_fn->init == NULL) {
VINE_LOGE("No init() defined");
return VINE_ERROR_OPERATION_FAILED;
if (disc_handle->plugin_fn->subscribe == NULL) {
VINE_LOGE("No subscribe() defined");
+ disc_handle->plugin_fn->deinit(plugin_handle);
+ disc_handle->plugin_handle = NULL;
return VINE_ERROR_OPERATION_FAILED;
}
error = disc_handle->plugin_fn->subscribe(plugin_handle, service_type, iface_name);
vine_disc_error error = VINE_DISC_ERROR_NONE;
vine_disc_s *disc_handle = (vine_disc_s *)disc;
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
if (disc_handle->plugin_fn->init == NULL) {
VINE_LOGE("No init() defined");
return VINE_ERROR_OPERATION_FAILED;
VINE_LOGD("service[%p], disc handle[%p]", service, disc);
vine_disc_s *disc_handle = (vine_disc_s *)disc;
- void *plugin_handle = disc_handle->plugin_handle;
- if (disc_handle->plugin_fn == NULL || disc_handle->plugin_fn->init == NULL) {
+ void *plugin_handle = NULL;
+
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
+ if (disc_handle->plugin_fn->init == NULL) {
VINE_LOGE("No init() defined");
return VINE_ERROR_OPERATION_FAILED;
}
+ vine_disc_error error = disc_handle->plugin_fn->init(&plugin_handle, disc);
+ RET_VAL_IF(error != VINE_DISC_ERROR_NONE,
+ __convert_disc_error_to_vine_error(error),
+ "Fail to init %d", error);
+ disc_handle->plugin_handle = plugin_handle;
VINE_LOGD("plugin handle[%p]", plugin_handle);
if (disc_handle->plugin_fn->resolve_ip == NULL) {
VINE_LOGE("No resolve_ip() defined");
+ disc_handle->plugin_fn->deinit(plugin_handle);
+ disc_handle->plugin_handle = NULL;
return VINE_ERROR_OPERATION_FAILED;
}
- vine_disc_error error = disc_handle->plugin_fn->resolve_ip(plugin_handle,
+ error = disc_handle->plugin_fn->resolve_ip(plugin_handle,
_vine_service_get_type(service), _vine_service_get_name(service),
_vine_service_get_host_name(service), _vine_service_get_iface_name(service));
if (error != VINE_DISC_ERROR_NONE) {
void *plugin_handle = disc_handle->plugin_handle;
VINE_LOGD("plugin handle[%p]", plugin_handle);
+ RET_VAL_IF(disc_handle->plugin_fn == NULL, VINE_ERROR_INVALID_OPERATION, "plugin_fn is NULL");
if (disc_handle->plugin_fn->cancel_resolve_ip == NULL) {
VINE_LOGE("No resolve_ip() defined");
return VINE_ERROR_OPERATION_FAILED;
ret = _vine_service_create(&discovered_service, false);
RET_IF(ret != VINE_ERROR_NONE, "Fail to create a service");
- ret = _vine_service_set_disc_handle(discovered_service, disc);
- RET_IF(ret != VINE_ERROR_NONE, "Fail to set disc_handle");
-
ret = __vine_set_discovered_service(discovered_service,
service_type, service_name, host_name, port, attr, iface_name);
if (ret != VINE_ERROR_NONE) {
vine_session_s *s = (vine_session_s *)session;
vine_disc_h disc_handle;
- ret = _vine_service_get_disc_handle(service, VINE_DISCOVERY_METHOD_DNS_SD, &disc_handle);
- RET_VAL_IF(ret != VINE_ERROR_NONE, ret, "Fail to _vine_service_get_disc_handle");
+ ret = vine_disc_create(s->disc_method, &disc_handle);
+ RET_VAL_IF(ret != VINE_ERROR_NONE, ret, "Fail to vine_disc_create");
+
+ ret = _vine_service_set_disc_handle(service, disc_handle);
+ RET_VAL_IF(ret != VINE_ERROR_NONE, ret, "Fail to set disc_handle");
_vine_service_set_ip_resolved_cb(service, callback, user_data);