LCOV - code coverage report
Current view: top level - net - remotetcpclient.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 11 16 68.8 %
Date: 2011-08-21 Functions: 3 5 60.0 %
Branches: 1 6 16.7 %

           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                 :        771 : 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                 :        771 :         return TcpClient::open_socket(hostname, port, timeout_connect, true);
      39                 :          0 :     } catch (const Xapian::NetworkTimeoutError & e) {
      40                 :            :         throw Xapian::NetworkTimeoutError(e.get_msg(), get_tcpcontext(hostname, port),
      41                 :          0 :                                           e.get_error_string());
      42                 :          0 :     } catch (const Xapian::NetworkError & e) {
      43                 :            :         throw Xapian::NetworkError(e.get_msg(), get_tcpcontext(hostname, port),
      44                 :          0 :                                    e.get_error_string());
      45                 :            :     }
      46                 :            : }
      47                 :            : 
      48                 :            : string
      49                 :        771 : RemoteTcpClient::get_tcpcontext(const string & hostname, int port)
      50                 :            : {
      51                 :        771 :     string result("remote:tcp(");
      52                 :        771 :     result += hostname;
      53                 :        771 :     result += ':';
      54                 :        771 :     result += str(port);
      55                 :        771 :     result += ')';
      56                 :          0 :     return result;
      57                 :            : }
      58                 :            : 
      59                 :        771 : RemoteTcpClient::~RemoteTcpClient()
      60                 :            : {
      61                 :        771 :     do_close();
      62 [ +  - ][ #  # ]:        771 : }
                 [ #  # ]

Generated by: LCOV version 1.8