static void __destroy_discovered_service(dns_sd_discovered_service_s *service)
{
- free(service);
+ delete service;
}
/*
if (*txt_record == NULL) {
ret = VINE_DISC_ERROR_OUT_OF_MEMORY;
VINE_LOGE("Out of memory");
+ } else {
+ *txt_record = memcpy(*txt_record, TXTRecordGetBytesPtr(&txt_ref), *txt_len);
}
-
- *txt_record = memcpy(*txt_record, TXTRecordGetBytesPtr(&txt_ref), *txt_len);
TXTRecordDeallocate(&txt_ref);
return ret;
}
struct sockaddr_storage addr;
socklen_t len = sizeof(addr);
int fd;
+ int ret;
fd = lws_get_socket_fd(wsi);
- getpeername(fd, (struct sockaddr*)&addr, &len);
+ ret = getpeername(fd, (struct sockaddr*)&addr, &len);
+ if (ret < 0) {
+ VINE_LOGE("Cannot get name of connected peer. errno[%d]", ret);
+ return;
+ }
if (addr.ss_family == AF_INET) {
struct sockaddr_in *s = (struct sockaddr_in*)&addr;
RET_IF(args == NULL, "args is NULL");
auto it = g_pollfds.find(args->fd);
- if (it == g_pollfds.end()) {
- VINE_LOGE("No fd[%d]", args->fd);
+ if (it != g_pollfds.end()) {
+ free(it->second);
+ g_pollfds.erase(it);
+ VINE_LOGI("websocket poll fd[%d] is removed.", args->fd);
+ } else {
+ VINE_LOGI("Cannot find fd[%d] but remove it from eventloop", args->fd);
}
- free(it->second);
- g_pollfds.erase(it);
- VINE_LOGI("websocket poll fd[%d] is removed.", args->fd);
-
if (g_callbacks.pollfd_cb)
g_callbacks.pollfd_cb(VINE_DATA_PATH_POLLFD_DEL, args->fd, args->events);
}
vine_service_foreach_attribute(service, __print_attr, NULL);
printf("\n");
fflush(stdout);
+ free(service_type);
+ free(service_name);
}
static void __discovered_cb(vine_session_h session, vine_service_h service,
size = ftell(file);
if (size < 0 || size >= SIZE_MAX - 1) {
+ fclose(file);
return -1;
}
buf = (unsigned char *)calloc(sizeof(unsigned char), size + 1);
static int send_message(vine_dp_h dp)
{
- int ret;
+ int ret = VINE_ERROR_NONE;
+
if (vine_configs.file)
ret = _send_message_from_file(dp);
else if (vine_configs.msg)