tools/xenstored: Introduce a wrapper for conn->funcs->can_{read, write}
authorJulien Grall <jgrall@amazon.com>
Thu, 24 Jun 2021 08:08:42 +0000 (09:08 +0100)
committerJulien Grall <jgrall@amazon.com>
Thu, 24 Jun 2021 08:08:42 +0000 (09:08 +0100)
commit3adfb50315d9b5643bec7a8a5378625f15986200
treea610285a916e4c7eb202ab3f2c86d4adea25896b
parenta8002238b49c3423c7081dfbac3580651f5242ef
tools/xenstored: Introduce a wrapper for conn->funcs->can_{read, write}

Currently, the callbacks can_read and can_write are called directly. This
doesn't allow us to add generic check and therefore requires duplication.

At the moment, one check that could benefit to be common is whether the
connection should ignored. The position is slightly different between
domain and socket because for the latter we want to check the state of
the file descriptor first.

In follow-up patches, there will be more potential generic checks.

This patch provides wrappers to read/write a connection and move
the check ->is_ignored after the callback for everyone.

This also requires to replace the direct call to domain_can_read()
and domain_can_write() with the new wrapper. At the same time,
both functions can now be static. Note that the implementations need
to be moved earlier in the file xenstored_domain.c to avoid
declaring the prototype.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_domain.c
tools/xenstore/xenstored_domain.h