Skip to content

Commit

Permalink
连接远程服务器, 忽略被信号中断的错误码
Browse files Browse the repository at this point in the history
Signed-off-by: spriteray <[email protected]>
  • Loading branch information
spriteray committed Mar 2, 2021
1 parent 39c7aa8 commit 1e97640
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ int32_t tcp_connect( const char * host, uint16_t port, int32_t (*options)(int32_

// 连接
rc = connect( fd, p->ai_addr, p->ai_addrlen );
if ( rc == -1 && errno != EINPROGRESS )
// 出错的情况下, 忽略EINPROGRESS, EINTR
if ( rc == -1
&& errno != EINTR
&& errno != EINPROGRESS )
{
close( fd );
continue;
Expand Down Expand Up @@ -350,8 +353,12 @@ int32_t udp_connect( struct sockaddr_storage * localaddr, struct sockaddr_storag
}

// 连接
int32_t rc = connect( newfd, (struct sockaddr *)remoteaddr, sizeof(struct sockaddr) );
if ( rc == -1 && errno != EINPROGRESS )
int32_t rc = connect( newfd,
(struct sockaddr *)remoteaddr, sizeof(struct sockaddr) );
// 出错的情况下, 忽略EINPROGRESS, EINTR
if ( rc == -1
&& errno != EINTR
&& errno != EINPROGRESS )
{
close( newfd );
return -3;
Expand Down

0 comments on commit 1e97640

Please sign in to comment.