Mercurial > vim
comparison src/channel.c @ 8334:ad4b00bf2984 v7.4.1459
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 28 22:33:46 2016 +0100
patch 7.4.1459
Problem: MS-Windows doesn't know socklen_t.
Solution: Use previous method for WIN32.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 28 Feb 2016 22:45:04 +0100 |
parents | 07713b8243ac |
children | 8fa75a4c39bd |
comparison
equal
deleted
inserted
replaced
8333:c49db21a70e2 | 8334:ad4b00bf2984 |
---|---|
679 if (waittime >= 0 && ret < 0) | 679 if (waittime >= 0 && ret < 0) |
680 { | 680 { |
681 struct timeval tv; | 681 struct timeval tv; |
682 fd_set rfds; | 682 fd_set rfds; |
683 fd_set wfds; | 683 fd_set wfds; |
684 #ifndef WIN32 | |
684 int so_error = 0; | 685 int so_error = 0; |
685 socklen_t so_error_len = sizeof(so_error); | 686 socklen_t so_error_len = sizeof(so_error); |
687 #endif | |
686 | 688 |
687 FD_ZERO(&rfds); | 689 FD_ZERO(&rfds); |
688 FD_SET(sd, &rfds); | 690 FD_SET(sd, &rfds); |
689 FD_ZERO(&wfds); | 691 FD_ZERO(&wfds); |
690 FD_SET(sd, &wfds); | 692 FD_SET(sd, &wfds); |
707 sock_close(sd); | 709 sock_close(sd); |
708 channel_free(channel); | 710 channel_free(channel); |
709 return NULL; | 711 return NULL; |
710 } | 712 } |
711 | 713 |
714 #ifdef WIN32 | |
712 /* On Win32: select() is expected to work and wait for up to the | 715 /* On Win32: select() is expected to work and wait for up to the |
713 * waittime for the socket to be open. | 716 * waittime for the socket to be open. */ |
714 * On Linux-like systems: See socket(7) for the behavior | 717 if (!FD_ISSET(sd, &wfds) || ret == 0) |
718 #else | |
719 /* On Linux-like systems: See socket(7) for the behavior | |
715 * After putting the socket in non-blocking mode, connect() will | 720 * After putting the socket in non-blocking mode, connect() will |
716 * return EINPROGRESS, select() will not wait (as if writing is | 721 * return EINPROGRESS, select() will not wait (as if writing is |
717 * possible), need to use getsockopt() to check if the socket is | 722 * possible), need to use getsockopt() to check if the socket is |
718 * actually connect. | 723 * actually connect. |
719 * We detect an failure to connect when both read and write fds | 724 * We detect an failure to connect when both read and write fds |
723 ret = getsockopt(sd, | 728 ret = getsockopt(sd, |
724 SOL_SOCKET, SO_ERROR, &so_error, &so_error_len); | 729 SOL_SOCKET, SO_ERROR, &so_error, &so_error_len); |
725 if (ret < 0 || (so_error != 0 | 730 if (ret < 0 || (so_error != 0 |
726 && so_error != EWOULDBLOCK | 731 && so_error != EWOULDBLOCK |
727 && so_error != ECONNREFUSED | 732 && so_error != ECONNREFUSED |
728 #ifdef EINPROGRESS | 733 # ifdef EINPROGRESS |
729 && so_error != EINPROGRESS | 734 && so_error != EINPROGRESS |
730 #endif | 735 # endif |
731 )) | 736 )) |
732 { | 737 { |
733 ch_errorn(channel, | 738 ch_errorn(channel, |
734 "channel_open: Connect failed with errno %d", | 739 "channel_open: Connect failed with errno %d", |
735 so_error); | 740 so_error); |
739 return NULL; | 744 return NULL; |
740 } | 745 } |
741 } | 746 } |
742 | 747 |
743 if (!FD_ISSET(sd, &wfds) || so_error != 0) | 748 if (!FD_ISSET(sd, &wfds) || so_error != 0) |
749 #endif | |
744 { | 750 { |
745 #ifndef WIN32 | 751 #ifndef WIN32 |
746 struct timeval end_tv; | 752 struct timeval end_tv; |
747 long elapsed_msec; | 753 long elapsed_msec; |
748 | 754 |