Re: [Evolution] IMAP scanning gets stuck



On Fri, 2001-11-23 at 17:34, Jeffrey Stedfast wrote:
On Fri, 2001-11-23 at 20:10, Ujwal S. Sathyam wrote:
[snip]

Anyways, we already set the socket to O_NONBLOCK before we connect() and
do a select() on the socket after afaik, so this doesn't seem to work on
linux systems.

The timeout on a blocking connect() in Linux can vary depending on the
destination IP address. I have seen timouts of 14 minutes for
destination outside the LAN. In my code, I usually set the socket to
O_NONBLOCK with fcntl() before doing the connect. I then use poll with a
10 second timeout (I have a pretty busy server), and that has always
worked well for me. 

This is basically what we are currently doing, but according to you it's
not working. We *do* set the socket to O_NONBLOCK with an fcntl() call
and then call connect() and then select() on the socket and a cancel_fd
which is basically the same as polling on the socket while also allowing
user-intervention.

as seen here:

      flags = fcntl (fd, F_GETFL);
      fcntl (fd, F_SETFL, flags | O_NONBLOCK);
      
      ret = connect (fd, (struct sockaddr *)&sin, sizeof (sin));
      if (ret == 0) {
              fcntl (fd, F_SETFL, flags);
              return fd;
      }
      
      if (errno != EINPROGRESS) {
              close (fd);
              return -1;
      }
      
      FD_ZERO (&rdset);
      FD_ZERO (&wrset);
      FD_SET (fd, &wrset);
      FD_SET (cancel_fd, &rdset);
      fdmax = MAX (fd, cancel_fd) + 1;
      tv.tv_usec = 0;
      tv.tv_sec = 60 * 4;
      
      if (select (fdmax, &rdset, &wrset, 0, &tv) <= 0) {
              close (fd);
              errno = ETIMEDOUT;
              return -1;
      }

Yes, that looks correct indeed, though I prefer to use poll. Which file
is this so that I can put in my debugging printfs to see if it is really
doing that? 4 minutes is pretty long. How about 30 seconds or 1 minute?
If I want to hack the source, do I get it from CVS HEAD or the 1.0
brach? If it is the branch, what is the exact tag?

Also, do you have the linger socket option set? I have found that the
option is set, close() sometimes blocks until the kernel decides to
actually close the connection.

Also, you were mentioning a Stop/Cancel button? Where is that? Just so
that you know, this is in the periodic mail check, not when I hit
Send/Receive. Even when I hit Send/Receive, sometimes hitting the cancel
button does not work.

Ujwal









[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]