Drop functions: - udscs_client_fill_fds() - udscs_client_handle_fds() These became obsolete with GMainLoop integration. Move required code to udscs_server_fill_fds() and udscs_server_handle_fds(), respectively. --- src/udscs.c | 48 ++++++++++++++---------------------------------- src/udscs.h | 16 ---------------- 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/src/udscs.c b/src/udscs.c index 3a1ea44..64f0307 100644 --- a/src/udscs.c +++ b/src/udscs.c @@ -276,7 +276,6 @@ static void udscs_read_complete(struct udscs_connection **connp) conn->header_read = 0; } -/* A helper for udscs_client_handle_fds() */ static void udscs_do_read(struct udscs_connection **connp) { ssize_t n; @@ -327,7 +326,6 @@ static void udscs_do_read(struct udscs_connection **connp) } } -/* A helper for udscs_client_handle_fds() */ static void udscs_do_write(struct udscs_connection **connp) { ssize_t n; @@ -361,32 +359,6 @@ static void udscs_do_write(struct udscs_connection **connp) } } -void udscs_client_handle_fds(struct udscs_connection **connp, fd_set *readfds, - fd_set *writefds) -{ - if (!*connp) - return; - - if (FD_ISSET((*connp)->fd, readfds)) - udscs_do_read(connp); - - if (*connp && FD_ISSET((*connp)->fd, writefds)) - udscs_do_write(connp); -} - -int udscs_client_fill_fds(struct udscs_connection *conn, fd_set *readfds, - fd_set *writefds) -{ - if (!conn) - return -1; - - FD_SET(conn->fd, readfds); - if (conn->write_buf) - FD_SET(conn->fd, writefds); - - return conn->fd + 1; -} - static gboolean udscs_io_channel_cb(GIOChannel *source, GIOCondition condition, gpointer data) @@ -580,9 +552,12 @@ int udscs_server_fill_fds(struct udscs_server *server, fd_set *readfds, conn = server->connections_head.next; while (conn) { - int conn_nfds = udscs_client_fill_fds(conn, readfds, writefds); - if (conn_nfds > nfds) - nfds = conn_nfds; + FD_SET(conn->fd, readfds); + if (conn->write_buf) + FD_SET(conn->fd, writefds); + + if (conn->fd >= nfds) + nfds = conn->fd + 1; conn = conn->next; } @@ -603,10 +578,15 @@ void udscs_server_handle_fds(struct udscs_server *server, fd_set *readfds, conn = server->connections_head.next; while (conn) { - /* conn maybe destroyed by udscs_client_handle_fds (when disconnected), - so get the next connection first. */ + /* conn may be destroyed by udscs_do_read() or udscs_do_write() + * (when disconnected), so get the next connection first. */ next_conn = conn->next; - udscs_client_handle_fds(&conn, readfds, writefds); + + if (FD_ISSET(conn->fd, readfds)) + udscs_do_read(&conn); + if (conn && FD_ISSET(conn->fd, writefds)) + udscs_do_write(&conn); + conn = next_conn; } } diff --git a/src/udscs.h b/src/udscs.h index 30a96db..48ecf90 100644 --- a/src/udscs.h +++ b/src/udscs.h @@ -78,22 +78,6 @@ struct udscs_connection *udscs_connect(const char *socketname, */ void udscs_destroy_connection(struct udscs_connection **connp); -/* Given a udscs client, fill the fd_sets pointed to by readfds and - * writefds for select() usage. - * Return value: value of the highest fd + 1 or -1 if conn is NULL - */ -int udscs_client_fill_fds(struct udscs_connection *conn, fd_set *readfds, - fd_set *writefds); - -/* Handle any events flagged by select for the given udscs client. - * Note that upon disconnection this will call the disconnect callback - * and then destroy the connection which will set *connp to NULL. - * - * Does nothing if *connp is NULL. - */ -void udscs_client_handle_fds(struct udscs_connection **connp, fd_set *readfds, - fd_set *writefds); - /* Queue a message for delivery to the client connected through conn. * Return value: 0 on success -1 on error (only happens when malloc fails). */ -- 2.13.6 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel