From: Martin Wilck <mwilck@xxxxxxxx> Currently the uxlsnr handles each client request (receive requset - handle request - respond) in a single loop iteration. This has severe disadvantages. In particular, the code may wait in poll() called from read_all(), or wait for the vecs lock, while other clients are ready to be serviced or signals to be handled. This patch adds some fields to "struct client" which will be used by later patches to change this into a state machine that basically waits only in place, the ppoll() call in uxsock_listen(). For now, we just introduce and initialize the fields. Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- multipathd/uxlsnr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c index 7bbec29..38a9d97 100644 --- a/multipathd/uxlsnr.c +++ b/multipathd/uxlsnr.c @@ -39,10 +39,30 @@ #include "main.h" #include "cli.h" #include "uxlsnr.h" +#include "strbuf.h" + +/* state of client connection */ +enum { + CLT_RECV, + CLT_PARSE, + CLT_LOCKED_WORK, + CLT_WORK, + CLT_SEND, +}; struct client { struct list_head node; + struct timespec expires; + int state; int fd; + vector cmdvec; + /* NUL byte at end */ + char cmd[_MAX_CMD_LEN + 1]; + struct strbuf reply; + struct handler *handler; + size_t cmd_len, len; + int error; + bool is_root; }; /* Indices for array of poll fds */ @@ -110,6 +130,7 @@ static void new_client(int ux_sock) } INIT_LIST_HEAD(&c->node); c->fd = fd; + c->state = CLT_RECV; /* put it in our linked list */ pthread_mutex_lock(&client_lock); @@ -125,6 +146,9 @@ static void _dead_client(struct client *c) int fd = c->fd; list_del_init(&c->node); c->fd = -1; + reset_strbuf(&c->reply); + if (c->cmdvec) + free_keys(c->cmdvec); free(c); close(fd); } -- 2.33.1 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel