]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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) 2011 New Dream Network | |
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_COMMON_OUTPUTDATASOCKET_H | |
16 | #define CEPH_COMMON_OUTPUTDATASOCKET_H | |
17 | ||
7c673cae FG |
18 | #include "common/Cond.h" |
19 | ||
7c673cae FG |
20 | class CephContext; |
21 | ||
22 | class OutputDataSocket : public Thread | |
23 | { | |
24 | public: | |
25 | OutputDataSocket(CephContext *cct, uint64_t _backlog); | |
26 | ~OutputDataSocket() override; | |
27 | ||
28 | bool init(const std::string &path); | |
29 | ||
30 | void append_output(bufferlist& bl); | |
31 | ||
32 | protected: | |
33 | virtual void init_connection(bufferlist& bl) {} | |
34 | void shutdown(); | |
35 | ||
36 | std::string create_shutdown_pipe(int *pipe_rd, int *pipe_wr); | |
37 | std::string bind_and_listen(const std::string &sock_path, int *fd); | |
38 | ||
39 | void *entry() override; | |
40 | bool do_accept(); | |
41 | ||
42 | void handle_connection(int fd); | |
43 | void close_connection(int fd); | |
44 | ||
45 | int dump_data(int fd); | |
46 | ||
47 | CephContext *m_cct; | |
48 | uint64_t data_max_backlog; | |
49 | std::string m_path; | |
50 | int m_sock_fd; | |
51 | int m_shutdown_rd_fd; | |
52 | int m_shutdown_wr_fd; | |
53 | bool going_down; | |
54 | ||
55 | uint64_t data_size; | |
56 | ||
57 | std::list<bufferlist> data; | |
58 | ||
59 | Mutex m_lock; | |
60 | Cond cond; | |
61 | ||
62 | bufferlist delim; | |
63 | }; | |
64 | ||
65 | #endif |