]> git.tue.mpg.de Git - paraslash.git/commitdiff
send: Avoid select-specific arguments in {pre,post}_select().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 3 Oct 2021 19:37:40 +0000 (21:37 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 25 Aug 2022 13:37:26 +0000 (15:37 +0200)
Just pass a pointer to struct sched instead of the fd sets. Since
two of the prototypes declared in send.h now refer to this structure,
sched.h must be included before send.h.

The udp sender implements neither ->pre_select() nor ->post_select(),
so we only need to fix the order in which send.h and sched.h are
included.

command.c
dccp_send.c
http_send.c
send.h
send_common.c
server.c
udp_send.c
vss.c

index e3f12931fd9d17fe5489636919a14379d60d0969..200ff054b35f0735cdb41cf09eda14b8b9b77826 100644 (file)
--- a/command.c
+++ b/command.c
@@ -22,8 +22,8 @@
 #include "net.h"
 #include "server.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "daemon.h"
 #include "fd.h"
index 5806bce3516c25ff600f31b073ba0760b40d4897..47d6b4089d8f7f229c27d3af262068f2d37ee2c3 100644 (file)
@@ -24,8 +24,8 @@
 #include "net.h"
 #include "server.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "fd.h"
 
@@ -36,14 +36,13 @@ struct dccp_fec_client {
        struct fec_client *fc;
 };
 
-static void dccp_pre_select(int *max_fileno, fd_set *rfds,
-               __a_unused fd_set *wfds)
+static void dccp_pre_select(struct sched *s)
 {
        unsigned n;
 
        FOR_EACH_LISTEN_FD(n, dss)
                if (dss->listen_fds[n] >= 0)
-                       para_fd_set(dss->listen_fds[n], rfds, max_fileno);
+                       para_fd_set(dss->listen_fds[n], &s->rfds, &s->max_fileno);
 }
 
 /**
@@ -119,7 +118,7 @@ static void dccp_send_fec(struct sender_client *sc, char *buf, size_t len)
                dccp_shutdown_client(sc);
 }
 
-static void dccp_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
+static void dccp_post_select(__a_unused struct sched *s)
 {
        struct sender_client *sc;
        struct dccp_fec_client *dfc;
index 39ef05a1db1a6fbbe86fea8f47153bcb06928366..6d026c715a09cf4a3599687cf7a5c5a2282c4a65 100644 (file)
@@ -20,8 +20,8 @@
 #include "server.h"
 #include "http.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "close_on_fork.h"
 #include "fd.h"
@@ -158,7 +158,7 @@ static void http_send(long unsigned current_chunk,
        }
 }
 
-static void http_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
+static void http_post_select(__a_unused struct sched *s)
 {
        struct sender_client *sc, *tmp;
        struct private_http_sender_data *phsd;
@@ -196,7 +196,7 @@ static void http_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
        phsd->status = HTTP_CONNECTED;
 }
 
-static void http_pre_select(int *max_fileno, fd_set *rfds, fd_set *wfds)
+static void http_pre_select(struct sched *s)
 {
        struct sender_client *sc, *tmp;
        unsigned n;
@@ -204,15 +204,15 @@ static void http_pre_select(int *max_fileno, fd_set *rfds, fd_set *wfds)
        FOR_EACH_LISTEN_FD(n, hss) {
                if (hss->listen_fds[n] < 0)
                        continue;
-               para_fd_set(hss->listen_fds[n], rfds, max_fileno);
+               para_fd_set(hss->listen_fds[n], &s->rfds, &s->max_fileno);
        }
        list_for_each_entry_safe(sc, tmp, &hss->client_list, node) {
                struct private_http_sender_data *phsd = sc->private_data;
                if (phsd->status == HTTP_CONNECTED) /* need to recv get request */
-                       para_fd_set(sc->fd, rfds, max_fileno);
+                       para_fd_set(sc->fd, &s->rfds, &s->max_fileno);
                if (phsd->status == HTTP_GOT_GET_REQUEST ||
                                phsd->status == HTTP_INVALID_GET_REQUEST)
-                       para_fd_set(sc->fd, wfds, max_fileno);
+                       para_fd_set(sc->fd, &s->wfds, &s->max_fileno);
        }
 }
 
diff --git a/send.h b/send.h
index 9eda2a17d76c6b97b4d4b46946fbb4832247b1d3..1d9db37ec82ab90714a38d96f2ab4e889eb07d9d 100644 (file)
--- a/send.h
+++ b/send.h
@@ -80,23 +80,20 @@ struct sender {
         * Add file descriptors to fd_sets.
         *
         * The pre_select function of each supported sender is called just before
-        * para_server enters its main select loop. Each sender may add its own
-        * file descriptors to the \a rfds or the \a wfds set.
-        *
-        * If a file descriptor was added, \a max_fileno must be increased by
-        * this function, if necessary.
+        * para_server enters its main select loop. Each sender may watch its own
+        * file descriptors for reading or writing.
         *
         * \sa select(2).
         */
-       void (*pre_select)(int *max_fileno, fd_set *rfds, fd_set *wfds);
+       void (*pre_select)(struct sched *s);
        /**
         * Handle the file descriptors which are ready for I/O.
         *
-        * If the pre_select hook added one ore more file descriptors to the
-        * read or write set, this is the hook to check the result and do any
-        * I/O on those descriptors which are ready for reading/writing.
+        * If the pre_select hook asked for one or more file descriptors to be
+        * watched, this is the hook to check the result and perform I/O on the
+        * descriptors which are ready for reading/writing.
         */
-       void (*post_select)(fd_set *rfds, fd_set *wfds);
+       void (*post_select)(struct sched *s);
        /**
         * Terminate all connected clients.
         *
index 227a3eb8469714dfd2e4c067fb06c2809ec94a81..ce167542c8c3178986037c806d88af6b0c4623f2 100644 (file)
 #include "afs.h"
 #include "server.h"
 #include "acl.h"
+#include "sched.h"
 #include "send.h"
 #include "close_on_fork.h"
 #include "chunk_queue.h"
-#include "sched.h"
 #include "vss.h"
 
 /** Clients will be kicked if there are more than that many bytes pending. */
index ce4ebf34ee680a4e24b9305879ef1b7ea248ba7e..ca00d0e9eb7c2635ae4aa534108e7e3f4a808cdc 100644 (file)
--- a/server.c
+++ b/server.c
@@ -24,8 +24,8 @@
 #include "net.h"
 #include "server.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "config.h"
 #include "close_on_fork.h"
index 68d75e3c3ef87dc089a3a1eec4d59fb647e73e44..ac656ff2cc02a47353fb73231fa96ad517dcd090 100644 (file)
@@ -21,8 +21,8 @@
 #include "net.h"
 #include "server.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "portable_io.h"
 #include "fd.h"
diff --git a/vss.c b/vss.c
index 23b64abbc2429d9b8a9baaa45e0ee16d881800e2..d2fbfb3424162afdab808d52bf40c33c83e61295 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -28,8 +28,8 @@
 #include "net.h"
 #include "server.h"
 #include "list.h"
-#include "send.h"
 #include "sched.h"
+#include "send.h"
 #include "vss.h"
 #include "ipc.h"
 #include "fd.h"
@@ -906,7 +906,7 @@ static void vss_pre_select(struct sched *s, void *context)
        FOR_EACH_SENDER(i) {
                if (!senders[i]->pre_select)
                        continue;
-               senders[i]->pre_select(&s->max_fileno, &s->rfds, &s->wfds);
+               senders[i]->pre_select(s);
        }
        vss_compute_timeout(s, vsst);
 }
@@ -1149,7 +1149,7 @@ static int vss_post_select(struct sched *s, void *context)
        FOR_EACH_SENDER(i) {
                if (!senders[i]->post_select)
                        continue;
-               senders[i]->post_select(&s->rfds, &s->wfds);
+               senders[i]->post_select(s);
        }
        if ((vss_playing() && !(mmd->vss_status_flags & VSS_PLAYING)) ||
                        (vss_next() && vss_playing()))