List:General Discussion« Previous MessageNext Message »
From:Batara Kesuma Date:July 10 2006 5:51am
Subject:EINTR in my_connect()
View as plain text  
Hi all,

Is there any reason to abort connection when error code is EINTR? I  
tried to patch it as below:

---

[batara@bia:~/src/mysql-5.0.22/libmysqld]$ diff -c client.c  
client.c.patch
*** client.c    2006-07-10 12:24:52.000000000 +0900
--- client.c.patch      2006-07-10 12:27:21.000000000 +0900
***************
*** 164,170 ****
     res= connect(fd, (struct sockaddr*) name, namelen);
     s_err= errno;                       /* Save the error... */
     fcntl(fd, F_SETFL, flags);
!   if ((res != 0) && (s_err != EINPROGRESS))
     {
       errno= s_err;                     /* Restore it */
       return(-1);
--- 164,170 ----
     res= connect(fd, (struct sockaddr*) name, namelen);
     s_err= errno;                       /* Save the error... */
     fcntl(fd, F_SETFL, flags);
!   if ((res != 0) && (s_err != EINPROGRESS) && (s_err != EINTR))
     {
       errno= s_err;                     /* Restore it */
       return(-1);

---

The reason is I have a lot of "Interrupted system call" error on my  
client side. I used this as my reference:
http://www.opengroup.org/onlinepubs/009695399/functions/connect.html

--
If the initiating socket is connection-mode, then connect() shall  
attempt to establish a connection to the address specified by the  
address argument. If the connection cannot be established immediately  
and O_NONBLOCK is not set for the file descriptor for the socket,  
connect() shall block for up to an unspecified timeout interval until  
the connection is established. If the timeout interval expires before  
the connection is established, connect() shall fail and the  
connection attempt shall be aborted. If connect() is interrupted by a  
signal that is caught while blocked waiting to establish a  
connection, connect() shall fail and set errno to [EINTR], but the  
connection request shall not be aborted, and the connection shall be  
established asynchronously.

If the connection cannot be established immediately and O_NONBLOCK is  
set for the file descriptor for the socket, connect() shall fail and  
set errno to [EINPROGRESS], but the connection request shall not be  
aborted, and the connection shall be established asynchronously.  
Subsequent calls to connect() for the same socket, before the  
connection is established, shall fail and set errno to [EALREADY].

--

I think for both EINPROGRESS and EINTR errno, the connection request  
should not be aborted. Is there anything that I missed here? Please  
advise, thank you.

Regards,
Batara




  
Thread
EINTR in my_connect()Batara Kesuma10 Jul