chiark / gitweb /
compile fixes for inotify
[innduct.git] / backends / innduct.c
index f28db2edfc6330259bbfe25225186f32b12c7dc9..6060ebd6240538dbcbe384b920194f3b67adea0e 100644 (file)
@@ -1,18 +1,10 @@
 /*
- * bugs
- *
-
- [740] <sit> info: processed feedfile(null) read=4(+0bl,+6err) offered=5(ch5,nc0) accepted=0(ch0+nc0) unwanted=0(0id+0bd+0nc) rejected=0(0id+0bd+0nc) deferred=0(0id+0bd+0nc) missing=2(0id+2bd+0nc) connretry=0(0id+0bd+0nc)
-
-   also unwanted should be nonzero I think
-
- [740] <sit> warning: corrupted file: /home/ian/things/Innfeed/inn2-2.4.5/fee, offset 349: line partially blanked: in `                                                  @050000002D130000006A0000000000000000@ <mi'..
-
-
-
+ * warning if no inotify
+ * inotify not working ?
  * some per-conn info thing for control
 
  * todo
  *  - actually do something with readable on control master
  *  - option for realsockdir
  *  - option for filepoll
@@ -1533,8 +1525,6 @@ static void conn_make_some_xmits(Conn *conn) {
        (abort(),-1);
 
       if (!artdata) art->missing= 1;
-fprintf(stderr,"INC %d %d?%d:%d\n",(int)art->state,
-       !!artdata, (int)RC_sent, (int)RC_missing);
       art->ipf->counts[art->state][ artdata ? RC_sent : RC_missing ]++;
 
       if (conn->stream) {
@@ -1569,7 +1559,6 @@ fprintf(stderr,"INC %d %d?%d:%d\n",(int)art->state,
       XMIT_LITERAL("\r\n");
 
       assert(art->state == art_Unchecked);
-fprintf(stderr,"INC %d %d\n",(int)art->state,(int)RC_sent);
       art->ipf->counts[art->state][RC_sent]++;
       LIST_ADDTAIL(conn->sent, art);
     }
@@ -1667,7 +1656,6 @@ static void update_nocheck(int accepted) {
 }
 
 static void article_done(Conn *conn, Article *art, int whichcount) {
-fprintf(stderr,"INC %d %d\n",(int)art->state,whichcount);
   if (!art->missing) art->ipf->counts[art->state][whichcount]++;
 
   if (whichcount == RC_accepted) update_nocheck(1);
@@ -1778,7 +1766,6 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev,
   case 335: /* IHAVE says send it */
     GET_ARTICLE(-1);
     assert(art->state == art_Unchecked);
-fprintf(stderr,"INC %d %d\n",(int)art->state,(int)RC_accepted);
     art->ipf->counts[art->state][RC_accepted]++;
     art->state= art_Wanted;
     LIST_ADDTAIL(conn->priority, art);
@@ -1926,7 +1913,7 @@ static void *feedfile_got_article(oop_source *lp, oop_read *rd,
   art->midlen= midlen;
   art->ipf= ipf;  ipf->inprogress++;
   art->token= TextToToken(tokentextbuf);
-  art->offset= ipf->offset;
+  art->offset= old_offset;
   art->blanklen= recsz;
   strcpy(art->messageid, space+1);
   LIST_ADDTAIL(queue, art);
@@ -2004,10 +1991,10 @@ static ssize_t tailing_try_read(struct oop_readable *rable, void *buffer,
 
 /*---------- filemon implemented with inotify ----------*/
 
-#if defined(HAVE_INOTIFY) && !defined(HAVE_FILEMON)
+#if defined(HAVE_SYS_INOTIFY_H) && !defined(HAVE_FILEMON)
 #define HAVE_FILEMON
 
-#include <linux/inotify.h>
+#include <sys/inotify.h>
 
 static int filemon_inotify_fd;
 static int filemon_inotify_wdmax;
@@ -2023,7 +2010,7 @@ static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) {
 
   if (wd >= filemon_inotify_wdmax) {
     int newmax= wd+2;
-    filemon_inotify_wd= xrealloc(filemon_inotify_wd2ipf,
+    filemon_inotify_wd2ipf= xrealloc(filemon_inotify_wd2ipf,
                                 sizeof(*filemon_inotify_wd2ipf) * newmax);
     memset(filemon_inotify_wd2ipf + filemon_inotify_wdmax, 0,
           sizeof(*filemon_inotify_wd2ipf) * (newmax - filemon_inotify_wdmax));
@@ -2042,7 +2029,7 @@ static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) {
 static void filemon_method_stopfile(InputFile *ipf, Filemon_Perfile *pf) {
   int wd= pf->wd;
   debug("filemon inotify stopfile %p wd=%d", ipf, wd);
-  int r= inotify_rm_watch(filemon_inotify_fd, filemon_inotify_wd);
+  int r= inotify_rm_watch(filemon_inotify_fd, wd);
   if (r) sysdie("inotify_rm_watch");
   filemon_inotify_wd2ipf[wd]= 0;
 }
@@ -2061,7 +2048,7 @@ static void *filemon_inotify_readable(oop_source *lp, int fd,
       die("inotify read %d bytes wanted struct of %d", r, (int)sizeof(iev));
     }
     InputFile *ipf= filemon_inotify_wd2ipf[iev.wd];
-    debug("filemon inotify readable read %p wd=%p", iev.wd, ipf);
+    debug("filemon inotify readable read %d wd=%p", iev.wd, ipf);
     filemon_callback(ipf);
   }
   return OOP_CONTINUE;
@@ -2070,11 +2057,11 @@ static void *filemon_inotify_readable(oop_source *lp, int fd,
 static int filemon_method_init(void) {
   filemon_inotify_fd= inotify_init();
   if (filemon_inotify_fd<0) {
-    syswarn("could not initialise inotify: inotify_init failed");
+    syswarn("filemon/inotify: inotify_init failed");
     return 0;
   }
-  set nonblock;
-  loop->on_fd(loop, filemon_inotify_fd, OOP_READ, filemon_inotify_readable);
+  xsetnonblock(filemon_inotify_fd, 1);
+  loop->on_fd(loop, filemon_inotify_fd, OOP_READ, filemon_inotify_readable, 0);
 
   debug("filemon inotify init filemon_inotify_fd=%d", filemon_inotify_fd);
   return 1;
@@ -2088,7 +2075,10 @@ static int filemon_method_init(void) {
 
 struct Filemon_Perfile { int dummy; };
 
-static int filemon_method_init(void) { return 0; }
+static int filemon_method_init(void) {
+  warn("filemon/dummy: no filemon method compiled in");
+  return 0;
+}
 static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) { }
 static void filemon_method_stopfile(InputFile *ipf, Filemon_Perfile *pf) { }
 
@@ -3275,7 +3265,7 @@ int main(int argc, char **argv) {
   control_init();
 
   if (!filemon_method_init()) {
-    warn("no file monitoring available, polling");
+    warn("filemon: no file monitoring available, polling");
     every(5,0,filepoll);
   }