diff --git a/src/swtpm/ctrlchannel.c b/src/swtpm/ctrlchannel.c index 1b30dc8..2e28884 100644 --- a/src/swtpm/ctrlchannel.c +++ b/src/swtpm/ctrlchannel.c @@ -101,6 +101,15 @@ int ctrlchannel_get_client_fd(struct ctrlchannel *cc) return cc->clientfd; } +int ctrlchannel_set_client_fd(struct ctrlchannel *cc, int fd) +{ + int clientfd = cc->clientfd; + + cc->clientfd = fd; + + return clientfd; +} + static int ctrlchannel_return_state(ptm_getstate *pgs, int fd) { uint32_t blobtype = be32toh(pgs->u.req.type); diff --git a/src/swtpm/ctrlchannel.h b/src/swtpm/ctrlchannel.h index 91e3192..b0b1f67 100644 --- a/src/swtpm/ctrlchannel.h +++ b/src/swtpm/ctrlchannel.h @@ -47,6 +47,7 @@ struct mainLoopParams; struct ctrlchannel *ctrlchannel_new(int fd, bool isclient); int ctrlchannel_get_fd(struct ctrlchannel *cc); int ctrlchannel_get_client_fd(struct ctrlchannel *cc); +int ctrlchannel_set_client_fd(struct ctrlchannel *cc, int fd); int ctrlchannel_process_fd(int fd, struct libtpms_callbacks *cbs, bool *terminate, diff --git a/src/swtpm/mainloop.c b/src/swtpm/mainloop.c index c754665..648678b 100644 --- a/src/swtpm/mainloop.c +++ b/src/swtpm/mainloop.c @@ -262,6 +262,7 @@ skip_process: if (ctrlclntfd >= 0) close(ctrlclntfd); + ctrlchannel_set_client_fd(mlp->cc, -1); if (mlp->fd >= 0) { close(mlp->fd);