chiark / gitweb /
wip make it compile; mid eliminate multiple conn lists
[innduct.git] / backends / innduct.c
index a2b3742b47ef924ff6675780ea744926cd1a101a..9ee13bc7d372cfd774a67f086ada6c5af9e88f54 100644 (file)
@@ -187,13 +187,13 @@ perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
 /*----- doubly linked lists -----*/
 
 #define ISNODE(T)   struct { T *succ, *pred; } node  /* must be at start */
-#define DEFLIST(T)  typedef struct { T *head, *tail, *tp; int count; } T##List
+#define DEFLIST(T)  typedef struct { T *hd, *tl, *tp; int count; } T##List
 
 #define NODE(n) (assert((void*)&(n)->node == &(n)), \
                 (struct node*)&(n)->node)
 
 #define LIST_CHECKCANHAVENODE(l,n) \
-  ((void)((n) == ((l).head))) /* just for the type check */
+  ((void)((n) == ((l).hd))) /* just for the type check */
 
 #define LIST_ADDSOMEHOW(l,n,list_addsomehow)           \
  ( LIST_CHECKCANHAVENODE(l,n),                         \
@@ -202,7 +202,7 @@ perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
    )
 
 #define LIST_REMSOMEHOW(l,list_remsomehow)     \
- ( (typeof((l).head))                          \
+ ( (typeof((l).hd))                            \
    ( (l).count                                 \
      ? ( (l).count--,                          \
         list_remsomehow((struct list*)&(l)) )  \
@@ -216,6 +216,10 @@ perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
 #define LIST_REMHEAD(l) LIST_REMSOMEHOW((l),list_remhead)
 #define LIST_REMTAIL(l) LIST_REMSOMEHOW((l),list_remtail)
 
+#define LIST_HEAD(l) ((typeof((l)->hd))(list_head((struct list*)&(l))))
+#define LIST_NEXT(n) ((typeof(n))list_succ(NODE((n))))
+#define LIST_BACK(n) ((typeof(n))list_pred(NODE((n))))
+
 #define LIST_REMOVE(l,n)                       \
  ( LIST_CHECKCANHAVENODE(l,n),                 \
    list_remove(NODE((n))),                     \
@@ -397,8 +401,8 @@ struct Conn {
 
 static oop_source *loop;
 
-static int nconns, until_connect;
-static ConnList idle, working, full;
+static int until_connect;
+static ConnList conns;
 static ArticleList queue;
 
 static char *path_lock, *path_flushing, *path_defer;
@@ -710,7 +714,7 @@ static void *connchild_event(oop_source *lp, int fd, oop_event e, void *u) {
   /* Phew! */
   setnonblock(conn->fd, 1);
   conn->max_queue= conn->stream ? max_queue_per_conn : 1;
-  LIST_ADDHEAD(idle, conn);
+  LIST_ADDHEAD(conns, conn);
   notice("#%d connected %s", conn->fd, conn->stream ? "streaming" : "plain");
   connect_attempt_discard();
   check_master_queue();