return 0;
}
+static bool conn_can_read(struct connection *conn)
+{
+ return conn->funcs->can_read(conn) && !conn->is_ignored;
+}
+
+static bool conn_can_write(struct connection *conn)
+{
+ return conn->funcs->can_write(conn) && !conn->is_ignored;
+}
+
/* This function returns index inside the array if succeed, -1 if fail */
static int set_fd(int fd, short events)
{
list_for_each_entry(conn, &connections, list) {
if (conn->domain) {
wrl_check_timeout(conn->domain, now, ptimeout);
- if (domain_can_read(conn) ||
- (domain_can_write(conn) &&
+ if (conn_can_read(conn) ||
+ (conn_can_write(conn) &&
!list_empty(&conn->out_list)))
*ptimeout = 0;
} else {
if (&next->list != &connections)
talloc_increase_ref_count(next);
- if (conn->funcs->can_read(conn))
+ if (conn_can_read(conn))
handle_input(conn);
if (talloc_free(conn) == 0)
continue;
talloc_increase_ref_count(conn);
- if (conn->funcs->can_write(conn))
+ if (conn_can_write(conn))
handle_output(conn);
if (talloc_free(conn) == 0)
continue;
return len;
}
+static bool domain_can_write(struct connection *conn)
+{
+ struct xenstore_domain_interface *intf = conn->domain->interface;
+
+ return ((intf->rsp_prod - intf->rsp_cons) != XENSTORE_RING_SIZE);
+}
+
+static bool domain_can_read(struct connection *conn)
+{
+ struct xenstore_domain_interface *intf = conn->domain->interface;
+
+ if (domain_is_unprivileged(conn) && conn->domain->wrl_credit < 0)
+ return false;
+
+ return (intf->req_cons != intf->req_prod);
+}
+
static const struct interface_funcs domain_funcs = {
.write = writechn,
.read = readchn,
barf_perror("Failed to write to event fd");
}
-bool domain_can_read(struct connection *conn)
-{
- struct xenstore_domain_interface *intf = conn->domain->interface;
-
- if (domain_is_unprivileged(conn) && conn->domain->wrl_credit < 0)
- return false;
-
- if (conn->is_ignored)
- return false;
-
- return (intf->req_cons != intf->req_prod);
-}
-
static bool domid_is_unprivileged(unsigned int domid)
{
return domid != 0 && domid != priv_domid;
domid_is_unprivileged(conn->domain->domid);
}
-bool domain_can_write(struct connection *conn)
-{
- struct xenstore_domain_interface *intf = conn->domain->interface;
-
- if (conn->is_ignored)
- return false;
-
- return ((intf->rsp_prod - intf->rsp_cons) != XENSTORE_RING_SIZE);
-}
-
static char *talloc_domain_path(void *context, unsigned int domid)
{
return talloc_asprintf(context, "/local/domain/%u", domid);
/* Returns the implicit path of a connection (only domains have this) */
const char *get_implicit_path(const struct connection *conn);
-/* Can connection attached to domain read/write. */
-bool domain_can_read(struct connection *conn);
-bool domain_can_write(struct connection *conn);
-
bool domain_is_unprivileged(struct connection *conn);
/* Remove node permissions for no longer existing domains. */