LCOV - code coverage report
Current view: top level - net - remotetcpserver.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core c2b6f1024d3a Lines: 2 2 100.0 %
Date: 2019-05-16 09:13:18 Functions: 2 2 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file remotetcpserver.h
       2                 :            :  *  @brief TCP/IP socket based server for RemoteDatabase.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2008,2010,2015 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                 :            : #ifndef XAPIAN_INCLUDED_REMOTETCPSERVER_H
      22                 :            : #define XAPIAN_INCLUDED_REMOTETCPSERVER_H
      23                 :            : 
      24                 :            : #include "tcpserver.h"
      25                 :            : 
      26                 :            : #include <xapian/database.h>
      27                 :            : #include <xapian/registry.h>
      28                 :            : #include <xapian/visibility.h>
      29                 :            : 
      30                 :            : #include <string>
      31                 :            : #include <vector>
      32                 :            : 
      33                 :            : /** TCP/IP socket based server for RemoteDatabase.
      34                 :            :  *
      35                 :            :  *  This class implements the server used by xapian-tcpsrv.
      36                 :            :  */
      37         [ -  + ]:        710 : class XAPIAN_VISIBILITY_DEFAULT RemoteTcpServer : public TcpServer {
      38                 :            :     /// Don't allow assignment.
      39                 :            :     void operator=(const RemoteTcpServer &);
      40                 :            : 
      41                 :            :     /// Don't allow copying.
      42                 :            :     RemoteTcpServer(const RemoteTcpServer &);
      43                 :            : 
      44                 :            :     /** Paths to the databases we will open.
      45                 :            :      *
      46                 :            :      *  Contains exactly one entry if writable, and at least one if not.
      47                 :            :      */
      48                 :            :     const std::vector<std::string> dbpaths;
      49                 :            : 
      50                 :            :     /** Is this a WritableDatabase? */
      51                 :            :     bool writable;
      52                 :            : 
      53                 :            :     /** Timeout between messages during a single operation (in seconds). */
      54                 :            :     double active_timeout;
      55                 :            : 
      56                 :            :     /** Timeout between operations (in seconds). */
      57                 :            :     double idle_timeout;
      58                 :            : 
      59                 :            :     /** Registry used for (un)serialisation. */
      60                 :            :     Xapian::Registry reg;
      61                 :            : 
      62                 :            :     /** Accept a connection and return the filedescriptor for it. */
      63                 :            :     int accept_connection();
      64                 :            : 
      65                 :            :   public:
      66                 :            :     /** Construct a RemoteTcpServer for a Database and start listening for
      67                 :            :      *  connections.
      68                 :            :      *
      69                 :            :      *  @param dbpaths_ The path(s) to the database(s) we should open.
      70                 :            :      *  @param host     The hostname or address for the interface to listen on
      71                 :            :      *                  (or "" to listen on all interfaces).
      72                 :            :      *  @param port     The TCP port number to listen on.
      73                 :            :      *  @param active_timeout   Timeout between messages during a single
      74                 :            :      *                          operation (in seconds).
      75                 :            :      *  @param idle_timeout     Timeout between operations (in seconds).
      76                 :            :      *  @param writable         Should we open the DB for writing?
      77                 :            :      *  @param verbose          Should we produce output when connections are
      78                 :            :      *                          made or lost?
      79                 :            :      */
      80                 :            :     RemoteTcpServer(const std::vector<std::string> &dbpaths_,
      81                 :            :                     const std::string &host, int port,
      82                 :            :                     double active_timeout, double idle_timeout,
      83                 :            :                     bool writable, bool verbose);
      84                 :            : 
      85                 :            :     /// Set the registry used for (un)serialisation.
      86                 :        710 :     void set_registry(const Xapian::Registry & reg_) { reg = reg_; }
      87                 :            : 
      88                 :            :     /** Handle a single connection on an already connected socket.
      89                 :            :      *
      90                 :            :      *  This method may be called by multiple threads.
      91                 :            :      */
      92                 :            :     void handle_one_connection(int socket);
      93                 :            : };
      94                 :            : 
      95                 :            : #endif // XAPIAN_INCLUDED_REMOTETCPSERVER_H

Generated by: LCOV version 1.11