mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-01-21 04:01:13 +00:00
swtpm: Implement ctrlchannel_set_client_fd()
Implement ctrlchannel_set_client_fd() to set a new client fd and return its current value. Use this new function to set the file descriptor to -1 upon closing its associate file descriptor in the main loop. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
75f9f0d300
commit
aa3999d387
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user