for systems with a broken select use u_sleep() to ensure the write
authorAndrew Tridgell <tridge@samba.org>
Mon, 23 Mar 1998 04:14:21 +0000 (04:14 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 23 Mar 1998 04:14:21 +0000 (04:14 +0000)
process doesn't chew too much cpu time.

io.c
util.c

diff --git a/io.c b/io.c
index e8e1ceb..54ceb28 100644 (file)
--- a/io.c
+++ b/io.c
@@ -234,6 +234,7 @@ static int writefd(int fd,char *buf,int len)
            /* hmmm, we got a write select on the fd and then failed to write.
               Why doesn't that mean that the fd is dead? It doesn't on some
               systems it seems (eg. IRIX) */
+           u_sleep(1000);
 #if 0
            fprintf(FERROR,"write exception\n");
            exit_cleanup(1);
diff --git a/util.c b/util.c
index 2a47945..927aa99 100644 (file)
--- a/util.c
+++ b/util.c
@@ -82,9 +82,9 @@ char *map_ptr(struct map_struct *map,off_t offset,int len)
 
   if (lseek(map->fd,offset,SEEK_SET) != offset ||
       (nread=read(map->fd,map->p,len)) != len) {
-    fprintf(FERROR,"EOF in map_ptr! (offset=%d len=%d nread=%d errno=%d)\n",
-           (int)offset, len, nread, errno);
-    exit_cleanup(1);
+         fprintf(FERROR,"EOF in map_ptr! (offset=%d len=%d nread=%d errno=%d)\n",
+                 (int)offset, len, nread, errno);
+         exit_cleanup(1);
   }
 
   map->p_offset = offset;
@@ -342,3 +342,13 @@ int copy_file(char *source, char *dest, mode_t mode)
 
        return 0;
 }
+
+/* sleep for a while via select */
+void u_sleep(int usec)
+{
+       struct timeval tv;
+
+       tv.tv_sec = 0;
+       tv.tv_usec = usec;
+       select(0, NULL, NULL, NULL, &tv);
+}