diff -pru dillo.cache.new/src/IO/IO.c dillo.my/src/IO/IO.c
--- dillo.cache.new/src/IO/IO.c	Fri Apr 26 10:05:49 2002
+++ dillo.my/src/IO/IO.c	Sun Jun  2 13:03:19 2002
@@ -90,7 +90,7 @@ static void IO_free(IOData_t *io)
   g_return_if_fail(IO_get(io->Key) == NULL);
 
   if (io->Flags & IOFlag_FreeIOVec)
-     g_free(io->IOVec.iov_base);
+     g_free(io->buffer_start);
   g_free(io);
 }
 
@@ -172,9 +172,7 @@ static gboolean IO_read(IOData_t *io)
 
 /*
  * Write data, from a specific buffer, into a file descriptor
- * (** Write operations MUST NOT free the buffer because the buffer
- *     start is modified.)
- * todo: Implement IOWrites, remove the constraint stated above.
+ * todo: Implement IOWrites.
  */
 static gboolean IO_write(IOData_t *io)
 {
@@ -194,7 +192,7 @@ static gboolean IO_write(IOData_t *io)
          if (errno == EINTR)
             ret = TRUE;
          else if (errno == EAGAIN)
-            ret = TRUE; /* todo: ??? */
+            ret = FALSE;
 
       } else if ( St < io->IOVec.iov_len ){
          /* Not all data written */
@@ -238,6 +236,9 @@ static gboolean IO_callback(GIOChannel *
       ret = IO_read(io);
    } else if ( cond & G_IO_OUT ){           /* Write */
       while ( IO_write(io) );
+      /* IO write may have freed 'io' */
+      if ((io = IO_get(io_key)) && io->Status == -EAGAIN)
+	 ret = TRUE;  /* wait for another G_IO_OUT event... */
    }
 
    if ( cond & G_IO_ERR ){     /* Error */
@@ -292,6 +293,7 @@ void a_IO_ccc(int Op, int Branch, ChainL
       /* Send query */
       switch (Op) {
       case OpStart:
+         io->buffer_start = io->IOVec.iov_base;
          io->Info = Info;
          Info->LocalKey = io;
          IO_submit(io);
@@ -310,6 +312,7 @@ void a_IO_ccc(int Op, int Branch, ChainL
       /* Receive answer */
       switch (Op) {
       case OpStart:
+         io->buffer_start = io->IOVec.iov_base;
          io->Info = Info;
          Info->LocalKey = io;
          a_Chain_link_new(a_IO_ccc, Info, CCC_BCK, a_Cache_ccc);
diff -pru dillo.cache.new/src/IO/IO.h dillo.my/src/IO/IO.h
--- dillo.cache.new/src/IO/IO.h	Sat Jun  1 19:08:17 2002
+++ dillo.my/src/IO/IO.h	Sun Jun  2 13:16:20 2002
@@ -40,6 +40,8 @@ typedef struct {
    void *ExtData;         /* External data reference (not used by IO.c) */
    void *Info;            /* CCC Info structure for this IO */
    GIOChannel *GioCh;     /* IO channel */
+   void *buffer_start;    /* PRIVATE, only for use in a_IO_ccc()! Records the 
+                             beginning of the buffer for future g_free() */
 } IOData_t;
 
 

