[Spice-devel] [PATCH] client: rename connect_unsecure to connect_to_peer (rhbz#653545)

Alon Levy alevy at redhat.com
Mon Feb 7 04:08:37 PST 2011


On Mon, Feb 07, 2011 at 01:30:21PM +0200, Uri Lublin wrote:
> Both connect_secure() and connect_unsecure() call connect_to_peer().
> 
> Prior to this commit spicec.log reported all connections as unsecure,
> as connect_secure() called connect_unsecure() to make the connection.

Nice work. ACK.

> ---
>  client/red_peer.cpp |   17 +++++++++++++----
>  client/red_peer.h   |    1 +
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/client/red_peer.cpp b/client/red_peer.cpp
> index 6ff5844..aa6a76f 100644
> --- a/client/red_peer.cpp
> +++ b/client/red_peer.cpp
> @@ -70,7 +70,7 @@ void RedPeer::cleanup()
>      }
>  }
> 
> -void RedPeer::connect_unsecure(const char* host, int portnr)
> +void RedPeer::connect_to_peer(const char* host, int portnr)
>  {
>      struct addrinfo ai, *result = NULL, *e;
>      char uaddr[INET6_ADDRSTRLEN+1];
> @@ -106,7 +106,7 @@ void RedPeer::connect_unsecure(const char* host, int portnr)
>              getnameinfo((struct sockaddr*)e->ai_addr, e->ai_addrlen,
>                          uaddr,INET6_ADDRSTRLEN, uport,32,
>                          NI_NUMERICHOST | NI_NUMERICSERV);
> -            LOG_INFO("Trying %s %s", uaddr, uport);
> +            LOG_DEBUG("Trying %s %s", uaddr, uport);
>              if (::connect(_peer, e->ai_addr, e->ai_addrlen) == SOCKET_ERROR) {
>                  err = sock_error();
>                  LOG_INFO("Connect failed: %s (%d)",
> @@ -115,7 +115,7 @@ void RedPeer::connect_unsecure(const char* host, int portnr)
>                  _peer = INVALID_SOCKET;
>                  continue;
>              }
> -            LOG_INFO("Connected to %s %s", uaddr, uport);
> +            LOG_DEBUG("Connected to %s %s", uaddr, uport);
>              break;
>          }
>          lock.unlock();
> @@ -132,6 +132,13 @@ void RedPeer::connect_unsecure(const char* host, int portnr)
>      }
>  }
> 
> +void RedPeer::connect_unsecure(const char* host, int portnr)
> +{
> +    connect_to_peer(host, portnr);
> +    ASSERT(_ctx == NULL && _ssl == NULL && _peer != INVALID_SOCKET);
> +    LOG_INFO("Connected to %s %d", host, portnr);
> +}
> +
>  bool RedPeer::verify_pubkey(X509* cert, const HostAuthOptions::PublicKey& key)
>  {
>      EVP_PKEY* cert_pubkey = NULL;
> @@ -472,9 +479,11 @@ void RedPeer::connect_secure(const ConnectionOptions& options, const char* host)
>      int return_code;
>      int auth_flags;
>      SslVerifyCbData auth_data;
> +    int portnr = options.secure_port;
> 
> -    connect_unsecure(host, options.secure_port);
> +    connect_to_peer(host, portnr);
>      ASSERT(_ctx == NULL && _ssl == NULL && _peer != INVALID_SOCKET);
> +    LOG_INFO("Connected to %s %d", host, portnr);
> 
>      try {
>  #if OPENSSL_VERSION_NUMBER >= 0x10000000L
> diff --git a/client/red_peer.h b/client/red_peer.h
> index a4310e6..53fd3c9 100644
> --- a/client/red_peer.h
> +++ b/client/red_peer.h
> @@ -136,6 +136,7 @@ protected:
>      void cleanup();
> 
>  private:
> +    void connect_to_peer(const char* host, int port);
>      void shutdown();
> 
>  private:
> -- 
> 1.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list