LCOV - code coverage report
Current view: top level - net - remotetcpclient.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 15 18 83.3 %
Date: 2019-06-30 05:20:33 Functions: 3 3 100.0 %
Branches: 13 31 41.9 %

           Branch data     Line data    Source code
       1                 :            : /** @file remotetcpclient.cc
       2                 :            :  *  @brief TCP/IP socket based RemoteDatabase implementation
       3                 :            :  */
       4                 :            : /* Copyright (C) 2008,2010 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU General Public License as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program; if not, write to the Free Software
      18                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #include <config.h>
      22                 :            : 
      23                 :            : #include "remotetcpclient.h"
      24                 :            : 
      25                 :            : #include <xapian/error.h>
      26                 :            : 
      27                 :            : #include "str.h"
      28                 :            : #include "tcpclient.h"
      29                 :            : 
      30                 :            : using namespace std;
      31                 :            : 
      32                 :            : int
      33                 :        391 : RemoteTcpClient::open_socket(const string & hostname, int port,
      34                 :            :                              double timeout_connect)
      35                 :            : {
      36                 :            :     // If TcpClient::open_socket() throws, fill in the context.
      37                 :            :     try {
      38         [ +  + ]:        391 :         return TcpClient::open_socket(hostname, port, timeout_connect, true);
      39                 :          0 :     } catch (const Xapian::NetworkTimeoutError & e) {
      40                 :          0 :         throw Xapian::NetworkTimeoutError(e.get_msg(), get_tcpcontext(hostname, port),
      41   [ #  #  #  #  :          0 :                                           e.get_error_string());
                   #  # ]
      42      [ -  -  + ]:         16 :     } catch (const Xapian::NetworkError & e) {
      43                 :          8 :         throw Xapian::NetworkError(e.get_msg(), get_tcpcontext(hostname, port),
      44         [ -  + ]:         16 :                                    e.get_error_string());
           [ -  +  -  + ]
      45                 :            :     }
      46                 :            : }
      47                 :            : 
      48                 :            : string
      49                 :        399 : RemoteTcpClient::get_tcpcontext(const string & hostname, int port)
      50                 :            : {
      51         [ +  - ]:        399 :     string result("remote:tcp(");
      52         [ +  - ]:        399 :     result += hostname;
      53         [ +  - ]:        399 :     result += ':';
      54 [ +  - ][ +  - ]:        399 :     result += str(port);
      55         [ +  - ]:        399 :     result += ')';
      56                 :        399 :     return result;
      57                 :            : }
      58                 :            : 
      59                 :       1149 : RemoteTcpClient::~RemoteTcpClient()
      60                 :            : {
      61                 :        383 :     do_close();
      62         [ -  + ]:        766 : }

Generated by: LCOV version 1.11