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