test/nstool: Fix fd leak in accept() loop
nstool loops on accept(), but failed to close the accepted socket fds before continuing on. So, with repeated commands it would eventually die with an EMFILE. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
527c822a3b
commit
e3b19530e4
1 changed files with 2 additions and 0 deletions
|
@ -201,6 +201,8 @@ static void cmd_hold(int argc, char *argv[])
|
||||||
rc = read(afd, &buf, sizeof(buf));
|
rc = read(afd, &buf, sizeof(buf));
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
die("read(): %s\n", strerror(errno));
|
die("read(): %s\n", strerror(errno));
|
||||||
|
|
||||||
|
close(afd);
|
||||||
} while (rc == 0);
|
} while (rc == 0);
|
||||||
|
|
||||||
unlink(sockpath);
|
unlink(sockpath);
|
||||||
|
|
Loading…
Reference in a new issue