On Fri, 2024-06-21 at 18:35 +0800, Geliang Tang wrote:

[...]

> @@ -224,24 +188,22 @@ static int make_server(int sotype, const char *ip, int 
> port,
>  
>  static int make_client(int sotype, const char *ip, int port)
>  {
> +     int family = is_ipv6(ip) ? AF_INET6 : AF_INET;
>       struct sockaddr_storage addr = {0};
>       socklen_t len;
>       int err, fd;
>  
> -     fd = make_socket(sotype, ip, port, &addr, &len);
> -     if (fd < 0)
> +     err = make_sockaddr(family, ip, port, &addr, &len);
> +     if (err)
>               return -1;
>  
> -     err = connect(fd, (void *)&addr, len);
> -     if (CHECK(err, "make_client", "connect")) {
> +     fd = connect_to_addr(sotype, &addr, len, NULL);

Nit: same nit about timeout, need to pass options here.

> +     if (CHECK(fd < 0, "connect_to_addr", "connect")) {
>               log_err("failed to connect client socket");
> -             goto fail;
> +             return -1;
>       }
>  
>       return fd;
> -fail:
> -     close(fd);
> -     return -1;
>  }
>  
>  static __u64 socket_cookie(int fd)



Reply via email to