non-thread safe functions are used like rand(), strerror().
this patch replace them with thread safe one.
and also this patch contains a change to fix a memory leak problem.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7917
Change-Id: Ibfa8cbdef468666c738ebd4d7ca725c2bd06dd05
int r = snprintf(buf, buflen, "unnamed:" SOCKET_FMT, fd);
if (r < 0)
{
- ERR("snprintf(): %s", strerror(errno));
+ ERR("snprintf(): %s", eina_error_msg_get(errno));
return EINA_FALSE;
}
else if ((size_t)r > buflen)
if (!inet_ntop(addr->sa_family, mem, p, sizeof(p)))
{
ERR("inet_ntop(%d, %p, %p, %zd): %s",
- addr->sa_family, mem, p, sizeof(p), strerror(errno));
+ addr->sa_family, mem, p, sizeof(p), eina_error_msg_get(errno));
return EINA_FALSE;
}
if (r < 0)
{
- ERR("could not snprintf(): %s", strerror(errno));
+ ERR("could not snprintf(): %s", eina_error_msg_get(errno));
return EINA_FALSE;
}
else if ((size_t)r > buflen)
if (!inet_ntop(result->ai_family, mem, ip, sizeof(ip)))
{
- ERR("could not convert IP to string: %s", strerror(errno));
+ ERR("could not convert IP to string: %s", eina_error_msg_get(errno));
goto end;
}
ctx->cb(result->ai_canonname, ip, result->ai_addr, result->ai_addrlen, (void *)ctx->data);
{
if (errno != EEXIST)
{
- ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno));
+ ERR("could not create parent directory '%s' of path '%s': %s", d, path, eina_error_msg_get(errno));
goto end;
}
}
if (mkdir(d, mode) != 0)
{
if (errno != EEXIST)
- ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno));
+ ERR("could not create parent directory '%s' of path '%s': %s", d, path, eina_error_msg_get(errno));
else
{
struct stat st;
ssize_t r = write(url_con->write_fd, slice.bytes, slice.len);
if (r == -1)
{
- ERR("Could not write to fd=%d: %s", url_con->write_fd, strerror(errno));
+ ERR("Could not write to fd=%d: %s", url_con->write_fd, eina_error_msg_get(errno));
break;
}
slice.bytes += r;
if (!eina_file_close_on_exec(pd->fd, close_on_exec))
{
- ERR("fcntl(" SOCKET_FMT ", F_SETFD): %s", pd->fd, strerror(errno));
+ ERR("fcntl(" SOCKET_FMT ", F_SETFD): %s", pd->fd, eina_error_msg_get(errno));
pd->close_on_exec = old;
return EINA_FALSE;
}
if (!eina_file_close_on_exec(client, EINA_TRUE))
{
int errno_bkp = errno;
- ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, strerror(errno));
+ ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, eina_error_msg_get(errno));
closesocket(client);
errno = errno_bkp;
return INVALID_SOCKET;
if (!eina_file_close_on_exec(fd, close_on_exec))
{
- ERR("fcntl(" SOCKET_FMT ", F_SETFD,): %s", fd, strerror(errno));
+ ERR("fcntl(" SOCKET_FMT ", F_SETFD,): %s", fd, eina_error_msg_get(errno));
pd->close_on_exec = old;
return EINA_FALSE;
}
flags = fcntl(fd, F_GETFD);
if (flags < 0)
{
- ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", fd, strerror(errno));
+ ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", fd, eina_error_msg_get(errno));
return EINA_FALSE;
}
Eo *o = data;
Efl_Net_Server_Udp_Data *pd = efl_data_scope_get(o, MY_CLASS);
const struct addrinfo *addr;
- Eina_Error err;
+ Eina_Error err = EINA_ERROR_NO_ERROR;
pd->resolver = NULL;
client = eina_hash_find(pd->clients, str);
if (client)
{
+ free(buf);
_efl_net_server_udp_client_feed(client, slice);
return;
}
efl_event_callback_add(client, EFL_IO_CLOSER_EVENT_CLOSED, _efl_net_server_udp_client_event_closed, o);
if (!efl_net_server_client_announce(o, client))
- return;
+ {
+ free(buf);
+ return;
+ }
+ free(buf);
_efl_net_server_udp_client_feed(client, slice);
}
if (errno)
{
err = errno;
- ERR("invalid port numer '%s': %s", bport, strerror(errno));
+ ERR("invalid port numer '%s': %s", bport, eina_error_msg_get(errno));
goto error_bind;
}
r = 0;
if (stat(path, &st) != 0)
{
- ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, strerror(errno));
+ ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, eina_error_msg_get(errno));
eina_stringshare_del(path);
*cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n);
continue;
if (stat(path, &st) != 0)
{
- ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, strerror(errno));
+ ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, eina_error_msg_get(errno));
eina_stringshare_del(path);
*cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n);
continue;