Re: [Evolution] IMAP scanning gets stuck
- From: Jeffrey Stedfast <fejj ximian com>
- To: "Ujwal S. Sathyam" <ujwal netbrowser com>
- Cc: Dan Winship <danw ximian com>, Evolution List <evolution ximian com>
- Subject: Re: [Evolution] IMAP scanning gets stuck
- Date: 23 Nov 2001 20:34:23 -0500
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;
}
Also, I seem to recall reading in some man page or another that the
linux connect() always blocks anyway? I could have sworn I read this a
while back after noticing that winsock was able to do non-blocking
connect()'s.
If you use O_NONBLOCK correctly, connect() can be made non-blocking. As
I said, that is what I do in my code.
yes, and we do...but it seems to be not working (by your account at
least).
Jeff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]