]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
net: Drop fd_set parameter from para_accept().
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 30 Sep 2021 20:18:43 +0000 (22:18 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 25 Aug 2022 13:37:26 +0000 (15:37 +0200)
As for read_nonblock(), the parameter is dispensable because it is
only used for an optimization to avoid a system call. Get rid of it
because it hinders the conversion from select(2) to poll(2).

afs.c
audiod.c
audiod.h
audiod_command.c
dccp_send.c
http_send.c
net.c
net.h
send.h
send_common.c
server.c

diff --git a/afs.c b/afs.c
index c2081db7b586e4f50df8c2ca58ddfa2ff541880f..9f32c8aadb14a2125914ce24d945c9b8f9d8d377 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -948,7 +948,7 @@ static int command_post_select(struct sched *s, void *context)
                free(client);
        }
        /* Accept connections on the local socket. */
-       ret = para_accept(ct->fd, &s->rfds, &unix_addr, sizeof(unix_addr), &fd);
+       ret = para_accept(ct->fd, &unix_addr, sizeof(unix_addr), &fd);
        if (ret < 0)
                PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
        if (ret <= 0)
index 482cce377801189ffdeec9aa0862834aa27248b2..693c031a00269e3b93148d9bfbfe4a3d7cf7cd09 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1092,7 +1092,7 @@ static int command_post_select(struct sched *s, void *context)
        ret = task_get_notification(ct->task);
        if (ret < 0)
                return ret;
-       ret = handle_connect(ct->fd, &s->rfds);
+       ret = handle_connect(ct->fd);
        if (ret < 0) {
                PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
                if (ret == -E_AUDIOD_TERM) {
index b40fdd6743faa4650888c2bdf69756d6c12e40d8..18fb75b3a9f50bb5146e883260b452802752834a 100644 (file)
--- a/audiod.h
+++ b/audiod.h
@@ -21,5 +21,5 @@ bool uid_is_whitelisted(uid_t uid);
 /* defined in audiod_command.c */
 void audiod_status_dump(bool force);
 void close_stat_clients(void);
-int handle_connect(int accept_fd, fd_set *rfds);
+int handle_connect(int accept_fd);
 void stat_client_write_item(int item_num);
index bb54dfab87f7965a18f6cccbe6bc4077c147fa29..19537cf0959f40effa9c64fa579e791e737338eb 100644 (file)
@@ -360,7 +360,6 @@ EXPORT_AUDIOD_CMD_HANDLER(version)
  * Handle arriving connections on the local socket.
  *
  * \param accept_fd The fd to accept connections on.
- * \param rfds If \a accept_fd is not set in \a rfds, do nothing.
  *
  * This is called in each iteration of the select loop. If there is an incoming
  * connection on \a accept_fd, this function reads the command sent by the peer,
@@ -373,7 +372,7 @@ EXPORT_AUDIOD_CMD_HANDLER(version)
  *
  * \sa \ref para_accept(), \ref recv_cred_buffer().
  * */
-int handle_connect(int accept_fd, fd_set *rfds)
+int handle_connect(int accept_fd)
 {
        int argc, ret, clifd;
        char buf[MAXLINE], **argv = NULL;
@@ -384,7 +383,7 @@ int handle_connect(int accept_fd, fd_set *rfds)
        char *errctx = NULL;
        const struct audiod_command_info *aci;
 
-       ret = para_accept(accept_fd, rfds, &unix_addr, sizeof(struct sockaddr_un), &clifd);
+       ret = para_accept(accept_fd, &unix_addr, sizeof(struct sockaddr_un), &clifd);
        if (ret <= 0)
                return ret;
        ret = recv_cred_buffer(clifd, buf, sizeof(buf) - 1);
index bca7ad6781e29d2bb1bea686d3971e02ede59909..5806bce3516c25ff600f31b073ba0760b40d4897 100644 (file)
@@ -119,14 +119,14 @@ static void dccp_send_fec(struct sender_client *sc, char *buf, size_t len)
                dccp_shutdown_client(sc);
 }
 
-static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds)
+static void dccp_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
 {
        struct sender_client *sc;
        struct dccp_fec_client *dfc;
        int tx_ccid;
        uint32_t k, n;
 
-       sc = accept_sender_client(dss, rfds);
+       sc = accept_sender_client(dss);
        if (!sc)
                return;
 
index 987145bf799c6d14d8012ba37d31a3f47edf0ea3..39ef05a1db1a6fbbe86fea8f47153bcb06928366 100644 (file)
@@ -158,7 +158,7 @@ static void http_send(long unsigned current_chunk,
        }
 }
 
-static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds)
+static void http_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
 {
        struct sender_client *sc, *tmp;
        struct private_http_sender_data *phsd;
@@ -188,7 +188,7 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds)
                        break;
                }
        }
-       sc = accept_sender_client(hss, rfds);
+       sc = accept_sender_client(hss);
        if (!sc)
                return;
        phsd = para_malloc(sizeof(*phsd));
diff --git a/net.c b/net.c
index e1951e5e8d87501b1ef9096d3f3df64117e904f0..4a6f9a63cd8475f8e7a0f583be3ac7e3d205c1a7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -801,25 +801,21 @@ int recv_buffer(int fd, char *buf, size_t size)
  * Wrapper around the accept system call.
  *
  * \param fd The listening socket.
- * \param rfds An optional fd_set pointer.
  * \param addr Structure which is filled in with the address of the peer socket.
  * \param size Should contain the size of the structure pointed to by \a addr.
  * \param new_fd Result pointer.
  *
- * Accept incoming connections on \a addr, retry if interrupted. If \a rfds is
- * not \p NULL, return 0 if \a fd is not set in \a rfds without calling accept().
+ * Accept incoming connections on addr, retry if interrupted.
  *
  * \return Negative on errors, zero if no connections are present to be accepted,
  * one otherwise.
  *
  * \sa accept(2).
  */
-int para_accept(int fd, fd_set *rfds, void *addr, socklen_t size, int *new_fd)
+int para_accept(int fd, void *addr, socklen_t size, int *new_fd)
 {
        int ret;
 
-       if (rfds && !FD_ISSET(fd, rfds))
-               return 0;
        do
                ret = accept(fd, (struct sockaddr *) addr, &size);
        while (ret < 0 && errno == EINTR);
diff --git a/net.h b/net.h
index 2256f376497b89d3382e2bf80ce09725ef64ab02..fd89dc5db0695ae6285484e0755ae0d28b286693 100644 (file)
--- a/net.h
+++ b/net.h
@@ -143,7 +143,7 @@ extern int generic_max_transport_msg_size(int sockfd);
 int recv_bin_buffer(int fd, char *buf, size_t size);
 int recv_buffer(int fd, char *buf, size_t size);
 
-int para_accept(int fd, fd_set *rfds, void *addr, socklen_t size, int *new_fd);
+int para_accept(int fd, void *addr, socklen_t size, int *new_fd);
 int create_local_socket(const char *name);
 int connect_local_socket(const char *name);
 int recv_cred_buffer(int, char *, size_t);
diff --git a/send.h b/send.h
index f6aafbb41a2bf9b089f2ddcc9968278dea734fa1..9eda2a17d76c6b97b4d4b46946fbb4832247b1d3 100644 (file)
--- a/send.h
+++ b/send.h
@@ -222,6 +222,6 @@ void generic_com_on(struct sender_status *ss, unsigned protocol);
 void generic_acl_deplete(struct list_head *acl);
 void generic_com_off(struct sender_status *ss);
 char *generic_sender_help(void);
-struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfds);
+struct sender_client *accept_sender_client(struct sender_status *ss);
 int send_queued_chunks(int fd, struct chunk_queue *cq);
 int parse_fec_url(const char *arg, struct sender_command_data *scd);
index 90242d5c9b5ccb125617004e16fbf9b64d5484f6..227a3eb8469714dfd2e4c067fb06c2809ec94a81 100644 (file)
@@ -343,7 +343,6 @@ void generic_com_off(struct sender_status *ss)
  * Accept a connection on the socket(s) this server is listening on.
  *
  * \param ss The sender whose listening fd is ready for reading.
- * \param rfds Passed to para_accept(),
  *
  * This accepts incoming connections on any of the listening sockets of the
  * server. If there is a connection pending, the function
@@ -367,7 +366,7 @@ void generic_com_off(struct sender_status *ss)
  * \sa \ref para_accept(), \ref mark_fd_nonblocking(), \ref acl_check_access(),
  * \ref cq_new(), \ref add_close_on_fork_list().
  */
-struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfds)
+struct sender_client *accept_sender_client(struct sender_status *ss)
 {
        struct sender_client *sc;
        int fd, ret;
@@ -376,7 +375,7 @@ struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfd
        FOR_EACH_LISTEN_FD(n, ss) {
                if (ss->listen_fds[n] < 0)
                        continue;
-               ret = para_accept(ss->listen_fds[n], rfds, NULL, 0, &fd);
+               ret = para_accept(ss->listen_fds[n], NULL, 0, &fd);
                if (ret < 0)
                        goto warn;
                if (ret == 0)
index 8c0dc44fe06b673243808d11044e6a0c03b676f0..ce4ebf34ee680a4e24b9305879ef1b7ea248ba7e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -337,7 +337,7 @@ static int command_task_accept(unsigned listen_idx, struct sched *s,
        pid_t child_pid;
        uint32_t *chunk_table;
 
-       ret = para_accept(sct->listen_fds[listen_idx], &s->rfds, NULL, 0, &new_fd);
+       ret = para_accept(sct->listen_fds[listen_idx], NULL, 0, &new_fd);
        if (ret <= 0)
                goto out;
        mmd->num_connects++;