]>
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 | ||
11fdf7f2 TL |
18 | #include "common/ceph_mutex.h" |
19 | #include "common/Thread.h" | |
9f95a23c | 20 | #include "include/common_fwd.h" |
11fdf7f2 | 21 | #include "include/buffer.h" |
7c673cae | 22 | |
7c673cae FG |
23 | |
24 | class OutputDataSocket : public Thread | |
25 | { | |
26 | public: | |
27 | OutputDataSocket(CephContext *cct, uint64_t _backlog); | |
28 | ~OutputDataSocket() override; | |
29 | ||
30 | bool init(const std::string &path); | |
31 | ||
f67539c2 | 32 | void append_output(ceph::buffer::list& bl); |
7c673cae FG |
33 | |
34 | protected: | |
f67539c2 | 35 | virtual void init_connection(ceph::buffer::list& bl) {} |
7c673cae FG |
36 | void shutdown(); |
37 | ||
38 | std::string create_shutdown_pipe(int *pipe_rd, int *pipe_wr); | |
39 | std::string bind_and_listen(const std::string &sock_path, int *fd); | |
40 | ||
41 | void *entry() override; | |
42 | bool do_accept(); | |
43 | ||
44 | void handle_connection(int fd); | |
45 | void close_connection(int fd); | |
46 | ||
47 | int dump_data(int fd); | |
48 | ||
49 | CephContext *m_cct; | |
50 | uint64_t data_max_backlog; | |
51 | std::string m_path; | |
52 | int m_sock_fd; | |
53 | int m_shutdown_rd_fd; | |
54 | int m_shutdown_wr_fd; | |
55 | bool going_down; | |
56 | ||
57 | uint64_t data_size; | |
494da23a | 58 | uint32_t skipped; |
7c673cae | 59 | |
f67539c2 | 60 | std::vector<ceph::buffer::list> data; |
7c673cae | 61 | |
11fdf7f2 TL |
62 | ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock"); |
63 | ceph::condition_variable cond; | |
f67539c2 | 64 | ceph::buffer::list delim; |
7c673cae FG |
65 | }; |
66 | ||
67 | #endif |