chiark / gitweb /
wip make it compile
authorIan Jackson <ian@liberator.(none)>
Sat, 24 Apr 2010 22:56:01 +0000 (23:56 +0100)
committerIan Jackson <ian@liberator.(none)>
Sat, 24 Apr 2010 22:56:01 +0000 (23:56 +0100)
backends/innduct.c

index de0a2bc19ef2ffa2af5b44e171793a85a442887a..0ccaa1c9d360d36c9e0b3c25169ca4903a4fe20e 100644 (file)
@@ -242,16 +242,20 @@ DEFLIST(Article);
 /*----- function predeclarations -----*/
 
 static void conn_check_work(Conn *conn);
+static void conn_make_some_xmits(Conn *conn);
+static void *conn_write_some_xmits(Conn *conn);
 
 static int filemon_init(void);
 static void filemon_setfile(int mainfeed_fd, const char *mainfeed_path);
 static void filemon_callback(void);
 
+static ConnList *conn_determine_right_list(Conn *conn);
 static void conn_assign_one_article(ConnList *connlist, Conn **last_assigned);
 static void statemc_setstate(StateMachineState newsms, int periods,
                             const char *forlog, const char *why);
 static void check_master_queue(void);
 
+static void postfork(const char *what);
 static void postfork_inputfile(InputFile *ipf);
 
 /*----- configuration options -----*/
@@ -466,13 +470,6 @@ logwrap(debug,    " debug",    LOG_DEBUG,   -1,    0);
 
 static void perhaps_close(int *fd) { if (*fd) { close(*fd); fd=0; } }
 
-static void *xmalloc(size_t sz) {
-  if (!sz) return 0;
-  void *r= malloc(sz);
-  if (r) return r;
-  sysdie("malloc (%ld bytes) failed", (unsigned long)sz);
-}
-
 static pid_t xfork(const char *what) {
   pid_t child;
 
@@ -574,7 +571,7 @@ static int samefile(const struct stat *a, const struct stat *b) {
          a->st_dev == b->st_dev);
 }
 
-static char *sanitise(const char *input, int len) {
+static char *sanitise(const char *input) {
   static char sanibuf[100]; /* returns pointer to this buffer! */
 
   const char *p= input;
@@ -582,8 +579,8 @@ static char *sanitise(const char *input, int len) {
   *q++= '`';
   for (;;) {
     if (q > sanibuf+sizeof(sanibuf)-8) { strcpy(q,"'.."); break; }
-    int c;
-    if (len<=0 || !(c= *p++)) { *q++= '\''; *q=0; break; }
+    int c= *p++;
+    if (!c) { *q++= '\''; *q=0; break; }
     if (c>=' ' && c<=126 && c!='\\') { *q++= c; continue; }
     sprintf(q,"\\x%02x",c);
     q += 4;
@@ -598,7 +595,7 @@ static pid_t connecting_child;
 
 static void connect_attempt_discard(void) {
   if (connecting_sockets[0])
-    loop->cancel_fd(connecting_sockets[0]);
+    cancel_fd_read_except(connecting_sockets[0]);
 
   perhaps_close(&connecting_sockets[0]);
   perhaps_close(&connecting_sockets[1]);
@@ -727,11 +724,11 @@ static void connect_start(void) {
     if (r) sysdie("connect: close parent socket in child");
 
     alarm(connection_setup_timeout);
-    if (NNTPconnect(remote_host, port, &cn_from, &cn_to, buf) < 0) {
+    if (NNTPconnect((char*)remote_host, port, &cn_from, &cn_to, buf) < 0) {
       if (buf[0]) fatal("connect: rejected: %s", sanitise(buf));
       else sysfatal("connect: connection attempt failed");
     }
-    if (NNTPsendpassword(remote_host, cn_from, cn_to) < 0)
+    if (NNTPsendpassword((char*)remote_host, cn_from, cn_to) < 0)
       sysfatal("connect: authentication failed");
     if (try_stream) {
       if (fputs("MODE STREAM\r\n", cn_to) ||
@@ -809,7 +806,8 @@ static void check_master_queue(void) {
       conn_assign_one_article(&working, &last_assigned);
     } else if (idle.head) {
       conn_assign_one_article(&idle, &last_assigned);
-    } else if (nconns < max_connections && queue.count >= max_queue_per_conn &&
+    } else if (nconns < max_connections &&
+              conn_total_queued_articles(conn) >= max_queue_per_conn &&
               !connecting_child && !until_connect) {
       until_connect= reconnect_delay_periods;
       connect_start();
@@ -826,7 +824,7 @@ static void conn_assign_one_article(ConnList *connlist, Conn **last_assigned) {
   LIST_REMOVE(*connlist, conn);
   Article *art= LIST_REMHEAD(queue);
   LIST_ADDTAIL(conn->queue, art);
-  LIST_ADD(*conn_determine_right_list(conn), conn);
+  LIST_ADDTAIL(*conn_determine_right_list(conn), conn);
 
   /* This slightly odd arrangement is so that we call conn_check_work
    * once after filling the queue for a new connection in
@@ -842,14 +840,14 @@ static int conn_total_queued_articles(Conn *conn) {
 
 static ConnList *conn_determine_right_list(Conn *conn) {
   int inqueue= conn_total_queued_articles(conn);
-  assert(inqueue <= max_queue);
+  assert(inqueue <= max_queue_per_conn);
   if (inqueue == 0) return &idle;
   if (inqueue == conn->max_queue) return &full;
   return &working;
 }
 
-static void *conn_writeable(oop_source *l, int fd, int ev, void *u) {
-  check_conn_work(u);
+static void *conn_writeable(oop_source *l, int fd, oop_event ev, void *u) {
+  conn_check_work(u);
   return OOP_CONTINUE;
 }
 
@@ -877,13 +875,13 @@ static void conn_check_work(Conn *conn)  {
 }
 
 static void vconnfail(Conn *conn, const char *fmt, va_list al)
-     __attribute__((printf,2,0));
+     __attribute__((__format__(printf,2,0)));
 
 static void vconnfail(Conn *conn, const char *fmt, va_list al) {
   int requeue[art_MaxState];
 
   Article *art;
-  while ((art= LIST_REMHEAD(conn->queue))) LIST_ADDTAIL(queue);
+  while ((art= LIST_REMHEAD(conn->queue))) LIST_ADDTAIL(queue, art);
   while ((art= LIST_REMHEAD(conn->sent))) {
     counts[art->state]++;
     if (art->state==art_Unsolicited) art->state= art_Unchecked;
@@ -908,7 +906,7 @@ static void vconnfail(Conn *conn, const char *fmt, va_list al) {
 }
 
 static void connfail(Connection *conn, const char *fmt, ...)
-     __attribute__((printf,2,3));
+     __attribute__((__format__(printf,2,3)));
 static void connfail(Connection *conn, const char *fmt, ...) {
   va_list al;
   va_start(al,fmt);