1 /*
2  * Copyright 2022 Meta
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _THRIFT_SERVER_TFDSERVER_H_
8 #define _THRIFT_SERVER_TFDSERVER_H_ 1
9 
10 #include <memory>
11 #include <vector>
12 
13 #include <thrift/transport/TServerTransport.h>
14 
15 namespace apache
16 {
17 namespace thrift
18 {
19 namespace transport
20 {
21 
22 class TFDServer : public TServerTransport
23 {
24 
25 public:
26 	/**
27 	 * Constructor.
28 	 *
29 	 * @param fd    file descriptor of the socket
30 	 */
31 	TFDServer(int fd);
32 	virtual ~TFDServer();
33 
34 	virtual bool isOpen() const override;
35 	virtual THRIFT_SOCKET getSocketFD() override;
36 	virtual void close() override;
37 
38 	virtual void interrupt() override;
39 	virtual void interruptChildren() override;
40 
41 protected:
TFDServer()42 	TFDServer() : TFDServer(-1){};
43 	virtual std::shared_ptr<TTransport> acceptImpl() override;
44 
45 	int fd;
46 	std::vector<std::shared_ptr<TTransport>> children;
47 };
48 } // namespace transport
49 } // namespace thrift
50 } // namespace apache
51 
52 #endif /* _THRIFT_SERVER_TFDSERVER_H_ */
53