comparison src/process.c @ 111369:e7a9eb3aa4ac

Backport r99752 from trunk
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 04 Nov 2010 15:54:28 -0400
parents 5a8705defdf9
children 121e3a019c49
comparison
equal deleted inserted replaced
111368:5a8705defdf9 111369:e7a9eb3aa4ac
3571 3571
3572 for (lres = res; lres; lres = lres->ai_next) 3572 for (lres = res; lres; lres = lres->ai_next)
3573 { 3573 {
3574 int optn, optbits; 3574 int optn, optbits;
3575 3575
3576 retry_connect:
3577
3576 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); 3578 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol);
3577 if (s < 0) 3579 if (s < 0)
3578 { 3580 {
3579 xerrno = errno; 3581 xerrno = errno;
3580 continue; 3582 continue;
3673 if (is_non_blocking_client && xerrno == EWOULDBLOCK) 3675 if (is_non_blocking_client && xerrno == EWOULDBLOCK)
3674 break; 3676 break;
3675 #endif 3677 #endif
3676 #endif 3678 #endif
3677 #endif 3679 #endif
3680
3681 #ifndef WINDOWSNT
3678 if (xerrno == EINTR) 3682 if (xerrno == EINTR)
3679 { 3683 {
3680 /* Unlike most other syscalls connect() cannot be called 3684 /* Unlike most other syscalls connect() cannot be called
3681 again. (That would return EALREADY.) The proper way to 3685 again. (That would return EALREADY.) The proper way to
3682 wait for completion is select(). */ 3686 wait for completion is select(). */
3683 int sc; 3687 int sc, len;
3684 SELECT_TYPE fdset; 3688 SELECT_TYPE fdset;
3685 retry_select: 3689 retry_select:
3686 FD_ZERO (&fdset); 3690 FD_ZERO (&fdset);
3687 FD_SET (s, &fdset); 3691 FD_SET (s, &fdset);
3688 QUIT; 3692 QUIT;
3689 sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0, 3693 sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0,
3690 (EMACS_TIME *)0); 3694 (EMACS_TIME *)0);
3691 if (sc == -1) 3695 if (sc == -1)
3692 { 3696 {
3693 if (errno == EINTR) 3697 if (errno == EINTR)
3694 goto retry_select; 3698 goto retry_select;
3695 else 3699 else
3696 report_file_error ("select failed", Qnil); 3700 report_file_error ("select failed", Qnil);
3697 } 3701 }
3698 eassert (sc > 0); 3702 eassert (sc > 0);
3699 { 3703
3700 int len = sizeof xerrno; 3704 len = sizeof xerrno;
3701 eassert (FD_ISSET (s, &fdset)); 3705 eassert (FD_ISSET (s, &fdset));
3702 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) 3706 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1)
3703 report_file_error ("getsockopt failed", Qnil); 3707 report_file_error ("getsockopt failed", Qnil);
3704 if (xerrno != 0) 3708 if (xerrno)
3705 errno = xerrno, report_file_error ("error during connect", Qnil); 3709 errno = xerrno, report_file_error ("error during connect", Qnil);
3706 else 3710 else
3707 break; 3711 break;
3708 } 3712 }
3709 } 3713 #endif /* !WINDOWSNT */
3710 3714
3711 immediate_quit = 0; 3715 immediate_quit = 0;
3712 3716
3713 /* Discard the unwind protect closing S. */ 3717 /* Discard the unwind protect closing S. */
3714 specpdl_ptr = specpdl + count1; 3718 specpdl_ptr = specpdl + count1;
3715 emacs_close (s); 3719 emacs_close (s);
3716 s = -1; 3720 s = -1;
3721
3722 #ifdef WINDOWSNT
3723 if (xerrno == EINTR)
3724 goto retry_connect;
3725 #endif
3717 } 3726 }
3718 3727
3719 if (s >= 0) 3728 if (s >= 0)
3720 { 3729 {
3721 #ifdef DATAGRAM_SOCKETS 3730 #ifdef DATAGRAM_SOCKETS