From: Juergen Gross <jgross@suse.com>
To: Julien Grall <julien@xen.org>, xen-devel@lists.xenproject.org
Cc: Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH v2 2/2] tools/xenstore: simplify xenstored main loop
Date: Mon, 17 May 2021 08:10:49 +0200 [thread overview]
Message-ID: <12b13143-717b-c288-b96b-50613dafc6d3@suse.com> (raw)
In-Reply-To: <24e89076-4440-a32e-f701-71957cc2a9e4@xen.org>
[-- Attachment #1.1.1: Type: text/plain, Size: 2926 bytes --]
On 14.05.21 19:05, Julien Grall wrote:
> Hi Juergen,
>
> On 14/05/2021 12:56, Juergen Gross wrote:
>> The main loop of xenstored is rather complicated due to different
>> handling of socket and ring-page interfaces. Unify that handling by
>> introducing interface type specific functions can_read() and
>> can_write().
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> V2:
>> - split off function vector introduction (Julien Grall)
>> ---
>> tools/xenstore/xenstored_core.c | 77 +++++++++++++++----------------
>> tools/xenstore/xenstored_core.h | 2 +
>> tools/xenstore/xenstored_domain.c | 2 +
>> 3 files changed, 41 insertions(+), 40 deletions(-)
>>
>> diff --git a/tools/xenstore/xenstored_core.c
>> b/tools/xenstore/xenstored_core.c
>> index 856f518075..883a1a582a 100644
>> --- a/tools/xenstore/xenstored_core.c
>> +++ b/tools/xenstore/xenstored_core.c
>> @@ -1659,9 +1659,34 @@ static int readfd(struct connection *conn, void
>> *data, unsigned int len)
>> return rc;
>> }
>> +static bool socket_can_process(struct connection *conn, int mask)
>> +{
>> + if (conn->pollfd_idx == -1)
>> + return false;
>> +
>> + if (fds[conn->pollfd_idx].revents & ~(POLLIN | POLLOUT)) {
>> + talloc_free(conn);
>> + return false;
>> + }
>> +
>> + return (fds[conn->pollfd_idx].revents & mask) && !conn->is_ignored;
>> +}
>> +
>> +static bool socket_can_write(struct connection *conn)
>> +{
>> + return socket_can_process(conn, POLLOUT);
>> +}
>> +
>> +static bool socket_can_read(struct connection *conn)
>> +{
>> + return socket_can_process(conn, POLLIN);
>> +}
>> +
>> const struct interface_funcs socket_funcs = {
>> .write = writefd,
>> .read = readfd,
>> + .can_write = socket_can_write,
>> + .can_read = socket_can_read,
>> };
>> static void accept_connection(int sock)
>> @@ -2296,47 +2321,19 @@ int main(int argc, char *argv[])
>> if (&next->list != &connections)
>> talloc_increase_ref_count(next);
>> - if (conn->domain) {
>> - if (domain_can_read(conn))
>> - handle_input(conn);
>> - if (talloc_free(conn) == 0)
>> - continue;
>> -
>> - talloc_increase_ref_count(conn);
>> - if (domain_can_write(conn) &&
>> - !list_empty(&conn->out_list))
>
> AFAICT, the check "!list_empty(&conn->out_list)" can be safely removed
> because write_messages() will check if the list is empty (list_top()
> returns NULL in this case). Is that correct?
Yes.
Juergen
[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2021-05-17 6:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 11:56 [PATCH v2 0/2] tools/xenstore: simplify xenstored main loop Juergen Gross
2021-05-14 11:56 ` [PATCH v2 1/2] tools/xenstore: move per connection read and write func hooks into a struct Juergen Gross
2021-05-14 16:33 ` Julien Grall
2021-05-17 6:07 ` Juergen Gross
2021-05-14 11:56 ` [PATCH v2 2/2] tools/xenstore: simplify xenstored main loop Juergen Gross
2021-05-14 17:05 ` Julien Grall
2021-05-17 6:10 ` Juergen Gross [this message]
2021-05-17 17:54 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12b13143-717b-c288-b96b-50613dafc6d3@suse.com \
--to=jgross@suse.com \
--cc=iwj@xenproject.org \
--cc=julien@xen.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).