LCOV - code coverage report
Current view: top level - net - remotetcpserver.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7028d852e609 Lines: 12 14 85.7 %
Date: 2019-02-17 14:59:59 Functions: 4 4 100.0 %
Branches: 14 35 40.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file remotetcpserver.cc
       2                 :            :  * @brief class for TCP/IP-based remote server.
       3                 :            :  */
       4                 :            : /* Copyright 1999,2000,2001 BrightStation PLC
       5                 :            :  * Copyright 2002 Ananova Ltd
       6                 :            :  * Copyright 2002,2003,2004,2005,2006,2007,2008,2010,2015 Olly Betts
       7                 :            :  *
       8                 :            :  * This program is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU General Public License as
      10                 :            :  * published by the Free Software Foundation; either version 2 of the
      11                 :            :  * License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This program is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :            :  * GNU General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU General Public License
      19                 :            :  * along with this program; if not, write to the Free Software
      20                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      21                 :            :  * USA
      22                 :            :  */
      23                 :            : 
      24                 :            : #include <config.h>
      25                 :            : 
      26                 :            : #include "remotetcpserver.h"
      27                 :            : 
      28                 :            : #include <xapian/error.h>
      29                 :            : 
      30                 :            : #include "remoteserver.h"
      31                 :            : 
      32                 :            : #include <iostream>
      33                 :            : 
      34                 :            : using namespace std;
      35                 :            : 
      36                 :            : /// The RemoteTcpServer constructor, taking a database and a listening port.
      37                 :        389 : RemoteTcpServer::RemoteTcpServer(const vector<std::string> &dbpaths_,
      38                 :            :                                  const std::string & host, int port,
      39                 :            :                                  double active_timeout_, double idle_timeout_,
      40                 :            :                                  bool writable_, bool verbose_)
      41                 :            :     : TcpServer(host, port, true, verbose_),
      42                 :            :       dbpaths(dbpaths_), writable(writable_),
      43 [ +  - ][ +  - ]:        389 :       active_timeout(active_timeout_), idle_timeout(idle_timeout_)
      44                 :            : {
      45                 :        350 : }
      46                 :            : 
      47                 :            : void
      48                 :        350 : RemoteTcpServer::handle_one_connection(int socket)
      49                 :            : {
      50                 :            :     try {
      51                 :            :         RemoteServer sserv(dbpaths, socket, socket,
      52         [ +  - ]:        350 :                            active_timeout, idle_timeout, writable);
      53         [ +  - ]:        350 :         sserv.set_registry(reg);
      54         [ +  + ]:        350 :         sserv.run();
      55                 :          2 :     } catch (const Xapian::NetworkTimeoutError &e) {
      56         [ +  - ]:          1 :         if (verbose)
      57 [ -  + ][ -  + ]:          1 :             cerr << "Connection timed out: " << e.get_description() << endl;
         [ -  + ][ -  + ]
      58      [ +  -  - ]:          1 :     } catch (const Xapian::Error &e) {
      59   [ #  #  #  #  :          0 :         cerr << "Got exception " << e.get_description() << endl;
             #  #  #  # ]
      60                 :          0 :     } catch (...) {
      61                 :            :         // ignore other exceptions
      62                 :            :     }
      63 [ +  - ][ +  - ]:       1906 : }
      64                 :            : 
      65                 :            : #ifdef DISABLE_GPL_LIBXAPIAN
      66                 :            : # error GPL source we cannot relicense included in libxapian
      67                 :            : #endif

Generated by: LCOV version 1.11