]> git.pond.sub.org Git - empserver/blobdiff - src/lib/empthread/io.c
Generation numbers to catch write back of stale copies
[empserver] / src / lib / empthread / io.c
index 5bbce8d9761eeec09437520c7ad7ba63e40d3243..3fcf164bf96a026232d6e5d4a06cc070c1dfdd18 100644 (file)
@@ -51,6 +51,7 @@
 #include <unistd.h>
 #include "empio.h"
 #include "empthread.h"
+#include "file.h"
 #include "ioqueue.h"
 #include "misc.h"
 #include "queue.h"
@@ -123,6 +124,9 @@ io_input(struct iop *iop, int waitforinput)
     int cc;
     int res;
 
+    if (waitforinput)
+       ef_make_stale();
+
     /* Not a read IOP */
     if ((iop->flags & IO_READ) == 0) {
        errno = EBADF;
@@ -183,6 +187,9 @@ io_output(struct iop *iop, int waitforoutput)
     int n;
     int remain;
 
+    if (waitforoutput)
+       ef_make_stale();
+
     /* If there is no output waiting. */
     if (!io_outputwaiting(iop))
        return 0;
@@ -264,6 +271,9 @@ io_write(struct iop *iop, char *buf, int nbytes, int doWait)
 {
     int len;
 
+    if (doWait)
+       ef_make_stale();
+
     if ((iop->flags & IO_WRITE) == 0)
        return -1;
     ioq_append(iop->output, buf, nbytes);
@@ -285,6 +295,8 @@ io_output_all(struct iop *iop)
 {
     int n;
 
+    ef_make_stale();
+
     /*
      * Mustn't block a player thread while update is pending, or else
      * a malicous player could delay the update indefinitely