Skip to content

Commit

Permalink
Close socket descriptor in checkPortIffUp. (#3263)
Browse files Browse the repository at this point in the history
What I did
Close socket descriptor in checkPortIffUp.

Why I did it
Currently the file descriptor is not closed. It will cause descriptor leak.
  • Loading branch information
mint570 authored Sep 24, 2024
1 parent 69cf087 commit 002cd25
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,15 @@ bool TeamMgr::checkPortIffUp(const string &port)
if (fd == -1 || ioctl(fd, SIOCGIFFLAGS, &ifr) == -1)
{
SWSS_LOG_ERROR("Failed to get port %s flags", port.c_str());
if (fd != -1)
{
close(fd);
}
return false;
}

SWSS_LOG_INFO("Get port %s flags %i", port.c_str(), ifr.ifr_flags);

close(fd);
return ifr.ifr_flags & IFF_UP;
}

Expand Down

0 comments on commit 002cd25

Please sign in to comment.