Author: adrian.chadd
Date: Wed Apr  1 16:12:49 2009
New Revision: 13898

Modified:
    branches/LUSCA_HEAD/libiapp/comm.c
    branches/LUSCA_HEAD/libiapp/comm.h
    branches/LUSCA_HEAD/libiapp/disk.c
    branches/LUSCA_HEAD/libiapp/mainloop.c

Log:
* Migrate some more of the disk related stuff from the comm fd state and  
into
   the disk specific stuff.



Modified: branches/LUSCA_HEAD/libiapp/comm.c
==============================================================================
--- branches/LUSCA_HEAD/libiapp/comm.c  (original)
+++ branches/LUSCA_HEAD/libiapp/comm.c  Wed Apr  1 16:12:49 2009
@@ -433,10 +433,15 @@
   *    This function has no way of cancelling pending connect()s; it'll just  
not call the
   *    callback on an invalid cbdata pointer.
   *
+ *     PREVIOUS COMMENT:
   *    The callback will currently never be called if comm_close() is called  
before
   *    the connect() has had time to complete (successfully or not.) This is  
in line with
   *    other comm_ related callbacks but may not be such a good idea moving  
forward.
   *
+ *     CURRENT COMMENT:
+ *     comm_close() is calling the connect completion callback if it hasn't  
yet finished..?
+ *     That needs to be sorted out!
+ *
   *    Like commConnectStart(), the connect() -may- succeed after the first  
call and
   *    the callback -may- be immediately called. Too much existing code (well, 
 
all 8 uses)
   *    currently relies on and works with this behaviour. This should be  
investigated
@@ -731,6 +736,28 @@

  #endif

+/*!
+ * @function
+ *     comm_close
+ * @abstract
+ *     Begin the process of closing down a socket / comm filedescriptor.
+ * @discussion
+ *     A bunch of things happen:
+ *     + Quit if the FD is a file, or is closing, or Squid is shutting down
+ *     + If the FD was connecting to a remote host, call the connect
+ *       completion callback with COMM_ERR_CLOSING
+ *     + call the close handlers
+ *     + Update the pconn counters
+ *     + If SSL; mark as closing down, and begin closing.. ?
+ *     + Finish the closing down process (ie, fd_close(), etc.)
+ *
+ *     TODO:
+ *         Unlike file_close(), I'm not sure whether this calls the
+ *         completion callback(s) anywhere on closing. This should
+ *         be documented and implemented!
+ *
+ * @param      fd              File descriptor to close
+ */
  void
  comm_close(int fd)
  {
@@ -886,6 +913,23 @@
      commUpdateEvents(fd);
  }

+
+/*!
+ * @function
+ *     commSetSelect
+ * @abstract
+ *     Register the given file descriptor for a comm notification
+ * @dicussion
+ *     The completion callback will not be called on comm_close();
+ *     so the owner needs to register a close handler if it wants
+ *     to be told.
+ *
+ * @param      fd              comm file descriptor (disk.c does this too?)
+ * @param      type            A union of COMM_SELECT_READ, COMM_SELECT_WRITE
+ * @param      handler         Notification callback
+ * @param      client_data     Notification callback data
+ * @param      timeout         If > 0, set the FD timeout - which triggers the 
timeout  
handler
+ */
  void
  commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,  
time_t timeout)
  {

Modified: branches/LUSCA_HEAD/libiapp/comm.h
==============================================================================
--- branches/LUSCA_HEAD/libiapp/comm.h  (original)
+++ branches/LUSCA_HEAD/libiapp/comm.h  Wed Apr  1 16:12:49 2009
@@ -71,7 +71,6 @@
      struct {
          unsigned int open:1;
          unsigned int close_request:1;
-        unsigned int write_daemon:1;
          unsigned int closing:1;
          unsigned int socket_eof:1;
          unsigned int nolinger:1;

Modified: branches/LUSCA_HEAD/libiapp/disk.c
==============================================================================
--- branches/LUSCA_HEAD/libiapp/disk.c  (original)
+++ branches/LUSCA_HEAD/libiapp/disk.c  Wed Apr  1 16:12:49 2009
@@ -86,7 +86,7 @@
  static int
  diskWriteIsComplete(int fd)
  {
-    return fd_table[fd].disk.write_q ? 0 : 1;
+    return fde_disk[fd].disk.write_q ? 0 : 1;
  }
  #endif

@@ -151,12 +151,20 @@
   * @abstract
   *    Flush queued data and close the file filedescriptor
   *
+ * @discussion
+ *     If there is a comm read handler registered on this file
+ *     descriptor, the callback is called with FD set to -1.
+ *
+ *     TODO: Does any code check the FD == -1 and treat errors?
+ *         It should be investigated, documented, and resolved..
+ *
   * @param     fd      Filedescriptor to close; must be open.
   */
  void
  file_close(int fd)
  {
      fde *F = &fd_table[fd];
+    struct _fde_disk *fdd = &fde_disk[fd];
      PF *read_callback;
      assert(fd >= 0);
      assert(F->flags.open);
@@ -164,7 +172,7 @@
        F->read_handler = NULL;
        read_callback(-1, F->read_data);
      }
-    if (F->flags.write_daemon) {
+    if (fdd->flags.write_daemon) {
  #if defined(_SQUID_WIN32_) || defined(_SQUID_OS2_)
        /*
         * on some operating systems, you can not delete or rename
@@ -257,7 +265,7 @@
      if (NULL == q)
        return;
      debug(6, 3) ("diskHandleWrite: FD %d\n", fd);
-    F->flags.write_daemon = 0;
+    fdd->flags.write_daemon = 0;
      assert(fdd->write_q != NULL);
      assert(fdd->write_q->len > fdd->write_q->buf_offset);
      debug(6, 3) ("diskHandleWrite: FD %d writing %d bytes\n",
@@ -340,7 +348,7 @@
        diskCombineWrites(fdd);
        cbdataLock(fdd->wrt_handle_data);
        commSetSelect(fd, COMM_SELECT_WRITE, diskHandleWrite, NULL, 0);
-       F->flags.write_daemon = 1;
+       fdd->flags.write_daemon = 1;
      }
      do_close = F->flags.close_request;
      if (fdd->wrt_handle) {

Modified: branches/LUSCA_HEAD/libiapp/mainloop.c
==============================================================================
--- branches/LUSCA_HEAD/libiapp/mainloop.c      (original)
+++ branches/LUSCA_HEAD/libiapp/mainloop.c      Wed Apr  1 16:12:49 2009
@@ -30,8 +30,8 @@
  #include "fd_types.h"
  #include "comm_types.h"
  #include "comm.h"
+#include "disk.h"
  #include "mainloop.h"
-

  /*
   * Configure the libraries required to bootstrap iapp.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to