mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 00:15:51 -04:00
Fix rsGetHostByNameSpecDNS by closing socket.
This commit is contained in:
parent
88d70e2edc
commit
4cc0b9f492
1 changed files with 7 additions and 0 deletions
|
@ -193,6 +193,11 @@ bool rsGetHostByNameSpecDNS(const std::string& servername, const std::string& ho
|
||||||
RS_DBG("Sending Packet:\n", hexDump(buf, curSendSize));
|
RS_DBG("Sending Packet:\n", hexDump(buf, curSendSize));
|
||||||
#endif
|
#endif
|
||||||
int s = socket(serverAddr.ss_family , SOCK_DGRAM , IPPROTO_UDP); //UDP packet for DNS queries
|
int s = socket(serverAddr.ss_family , SOCK_DGRAM , IPPROTO_UDP); //UDP packet for DNS queries
|
||||||
|
if(s<0)
|
||||||
|
{
|
||||||
|
RS_ERR("Could not open socket.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout_s > -1)
|
if (timeout_s > -1)
|
||||||
rs_setSockTimeout(s, true, timeout_s);
|
rs_setSockTimeout(s, true, timeout_s);
|
||||||
|
@ -205,6 +210,7 @@ bool rsGetHostByNameSpecDNS(const std::string& servername, const std::string& ho
|
||||||
if( send_size < 0)
|
if( send_size < 0)
|
||||||
{
|
{
|
||||||
RS_ERR("Send Failed with size = ", send_size);
|
RS_ERR("Send Failed with size = ", send_size);
|
||||||
|
close(s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +227,7 @@ bool rsGetHostByNameSpecDNS(const std::string& servername, const std::string& ho
|
||||||
, (struct sockaddr*)&serverAddr
|
, (struct sockaddr*)&serverAddr
|
||||||
, &sa_size
|
, &sa_size
|
||||||
);
|
);
|
||||||
|
close(s); // No more need of this socket, close it.
|
||||||
if(rec_size <= 0)
|
if(rec_size <= 0)
|
||||||
{
|
{
|
||||||
RS_ERR("Receive Failed");
|
RS_ERR("Receive Failed");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue