1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

DHCPClient: Close outgoing sockets after use

This commit is contained in:
Tim Schumacher 2022-04-11 00:01:58 +02:00 committed by Andreas Kling
parent ede818cbf9
commit 1bdaee475b

View file

@ -10,6 +10,7 @@
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <AK/Random.h>
#include <AK/ScopeGuard.h>
#include <AK/Try.h>
#include <LibCore/File.h>
#include <LibCore/Timer.h>
@ -40,6 +41,8 @@ static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, C
return false;
}
ScopeGuard socket_close_guard = [&] { close(fd); };
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, iface.ifname.characters(), IFNAMSIZ) < 0) {
dbgln("ERROR: setsockopt(SO_BINDTODEVICE) :: {}", strerror(errno));
return false;