Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / msg / simple / Accepter.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software 
11  * Foundation.  See file COPYING.
12  * 
13  */
14
15 #ifndef CEPH_MSG_ACCEPTER_H
16 #define CEPH_MSG_ACCEPTER_H
17
18 #include "common/Thread.h"
19
20 class SimpleMessenger;
21 struct entity_addr_t;
22
23 /**
24  * If the SimpleMessenger binds to a specific address, the Accepter runs
25  * and listens for incoming connections.
26  */
27 class Accepter : public Thread {
28   SimpleMessenger *msgr;
29   bool done;
30   int listen_sd;
31   uint64_t nonce;
32   int shutdown_rd_fd;
33   int shutdown_wr_fd;
34   int create_selfpipe(int *pipe_rd, int *pipe_wr);
35
36 public:
37   Accepter(SimpleMessenger *r, uint64_t n) 
38     : msgr(r), done(false), listen_sd(-1), nonce(n),
39       shutdown_rd_fd(-1), shutdown_wr_fd(-1)
40     {}
41     
42   void *entry() override;
43   void stop();
44   int bind(const entity_addr_t &bind_addr, const set<int>& avoid_ports);
45   int rebind(const set<int>& avoid_port);
46   int start();
47 };
48
49
50 #endif