| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.5"/> |
| <title>Apache Mesos: 3rdparty/libprocess/src/libevent_ssl_socket.hpp Source File</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0"> |
| <tbody> |
| <tr style="height: 56px;"> |
| <td style="padding-left: 0.5em;"> |
| <div id="projectname">Apache Mesos |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.5 --> |
| <div id="navrow1" class="tabs"> |
| <ul class="tablist"> |
| <li><a href="index.html"><span>Main Page</span></a></li> |
| <li><a href="pages.html"><span>Related Pages</span></a></li> |
| <li><a href="namespaces.html"><span>Namespaces</span></a></li> |
| <li><a href="annotated.html"><span>Classes</span></a></li> |
| <li class="current"><a href="files.html"><span>Files</span></a></li> |
| <li><a href="examples.html"><span>Examples</span></a></li> |
| </ul> |
| </div> |
| <div id="navrow2" class="tabs2"> |
| <ul class="tablist"> |
| <li><a href="files.html"><span>File List</span></a></li> |
| <li><a href="globals.html"><span>File Members</span></a></li> |
| </ul> |
| </div> |
| <div id="nav-path" class="navpath"> |
| <ul> |
| <li class="navelem"><a class="el" href="dir_8cab8f464681f7cc51cee77e79a434cd.html">3rdparty</a></li><li class="navelem"><a class="el" href="dir_043a76de98701f9bddf61b5e98f305ff.html">libprocess</a></li><li class="navelem"><a class="el" href="dir_01cbbd8dcbf9de3825992568658f467e.html">src</a></li> </ul> |
| </div> |
| </div><!-- top --> |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">libevent_ssl_socket.hpp</div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <a href="libevent__ssl__socket_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div> |
| <div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// you may not use this file except in compliance with the License.</span></div> |
| <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">// You may obtain a copy of the License at</span></div> |
| <div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">//</span></div> |
| <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div> |
| <div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">//</span></div> |
| <div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div> |
| <div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div> |
| <div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div> |
| <div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// See the License for the specific language governing permissions and</span></div> |
| <div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// limitations under the License</span></div> |
| <div class="line"><a name="l00012"></a><span class="lineno"> 12</span> </div> |
| <div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="preprocessor">#ifndef __LIBEVENT_SSL_SOCKET_HPP__</span></div> |
| <div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="preprocessor"></span><span class="preprocessor">#define __LIBEVENT_SSL_SOCKET_HPP__</span></div> |
| <div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor"></span></div> |
| <div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="preprocessor">#include <event2/buffer.h></span></div> |
| <div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#include <event2/bufferevent_ssl.h></span></div> |
| <div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#include <event2/event.h></span></div> |
| <div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#include <event2/listener.h></span></div> |
| <div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include <event2/util.h></span></div> |
| <div class="line"><a name="l00021"></a><span class="lineno"> 21</span> </div> |
| <div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include <atomic></span></div> |
| <div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include <memory></span></div> |
| <div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div> |
| <div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include <<a class="code" href="queue_8hpp.html">process/queue.hpp</a>></span></div> |
| <div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#include <<a class="code" href="libprocess_2include_2process_2socket_8hpp.html">process/socket.hpp</a>></span></div> |
| <div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div> |
| <div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="keyword">namespace </span><a class="code" href="namespaceos.html#ae19e4161a51b86a1f330f3bf1dc75389">process</a> {</div> |
| <div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="keyword">namespace </span>network {</div> |
| <div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">namespace </span>internal {</div> |
| <div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div> |
| <div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html"> 32</a></span> <span class="keyword">class </span><a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html">LibeventSSLSocketImpl</a> : <span class="keyword">public</span> <a class="code" href="classprocess_1_1network_1_1internal_1_1SocketImpl.html">SocketImpl</a></div> |
| <div class="line"><a name="l00033"></a><span class="lineno"> 33</span> {</div> |
| <div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="keyword">public</span>:</div> |
| <div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  <span class="comment">// See 'Socket::create()'.</span></div> |
| <div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keyword">static</span> <a class="code" href="classTry.html">Try<std::shared_ptr<SocketImpl></a>> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a03be9e1fa4bf9b0e48ca60c9ca7f360a">create</a>(<span class="keywordtype">int</span> <a class="code" href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#a303670cfc45c0e1a564fec0532320804">s</a>);</div> |
| <div class="line"><a name="l00037"></a><span class="lineno"> 37</span> </div> |
| <div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#acada5b553dea2903f2744b26a464f98a">LibeventSSLSocketImpl</a>(<span class="keywordtype">int</span> _s);</div> |
| <div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div> |
| <div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#ad2077833906c7d37189588ff67b43a20">~LibeventSSLSocketImpl</a>() <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00041"></a><span class="lineno"> 41</span> </div> |
| <div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="comment">// Implement 'SocketImpl' interface.</span></div> |
| <div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <a class="code" href="classprocess_1_1Future.html">Future<Nothing></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a4ee00c94cb838618b65c5f231e7c367a">connect</a>(<span class="keyword">const</span> <a class="code" href="classprocess_1_1network_1_1Address.html">Address</a>& <a class="code" href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#a2289c8b4a10fae48e88518019c900c5a">address</a>) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <a class="code" href="classprocess_1_1Future.html">Future<size_t></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a25118017aa15a1ee25039e69fdfd8ea4">recv</a>(<span class="keywordtype">char</span>* data, <span class="keywordtype">size_t</span> <a class="code" href="namespaceos_1_1stat.html#aac17a91dd3f91341b8c4021025e89b04">size</a>) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="comment">// Send does not currently support discard. See implementation.</span></div> |
| <div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <a class="code" href="classprocess_1_1Future.html">Future<size_t></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a6c91fd87e95efe9c12fe77e02bf306da">send</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* data, <span class="keywordtype">size_t</span> size) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <a class="code" href="classprocess_1_1Future.html">Future<size_t></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a3ee2460274ef43b0665de263b08e3539">sendfile</a>(<a class="code" href="int__fd_8hpp.html#aea4dbda01c90455f158ffa9b924c2f07">int_fd</a> fd, off_t offset, <span class="keywordtype">size_t</span> size) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <a class="code" href="classTry.html">Try<Nothing></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a107ac49390f671b4cd5d180e5bddb4ad">listen</a>(<span class="keywordtype">int</span> backlog) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <a class="code" href="classprocess_1_1Future.html">Future<std::shared_ptr<SocketImpl></a>> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a5dd3f53871f2152a0092a222ff63a778">accept</a>() <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#ad0ecd3ed460c9cf93b32e4d68b0107e7"> 50</a></span>  <a class="code" href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#ab1b898c86d5d9d449a65381c2b1d74f5">SocketImpl::Kind</a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#ad0ecd3ed460c9cf93b32e4d68b0107e7">kind</a>()<span class="keyword"> const override </span>{ <span class="keywordflow">return</span> SocketImpl::Kind::SSL; }</div> |
| <div class="line"><a name="l00051"></a><span class="lineno"> 51</span> </div> |
| <div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="comment">// Shuts down the socket.</span></div> |
| <div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="comment">//</span></div> |
| <div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="comment">// NOTE: Although this method accepts an integer which specifies the</span></div> |
| <div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="comment">// shutdown mode, this parameter is ignored because SSL connections</span></div> |
| <div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="comment">// do not have a concept of read/write-only shutdown. If either end</span></div> |
| <div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="comment">// of the socket is closed, then the futures of any outstanding read</span></div> |
| <div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="comment">// requests will be completed (possibly as failures).</span></div> |
| <div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <a class="code" href="classTry.html">Try<Nothing></a> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a94cb94e04c583bc9ee9df66c7a4684cf">shutdown</a>(<span class="keywordtype">int</span> how) <span class="keyword">override</span>;</div> |
| <div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div> |
| <div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="comment">// We need a post-initializer because 'shared_from_this()' is not</span></div> |
| <div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <span class="comment">// valid until the constructor has finished.</span></div> |
| <div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keywordtype">void</span> <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a0585a14478590e525165a418df7beb3a">initialize</a>();</div> |
| <div class="line"><a name="l00064"></a><span class="lineno"> 64</span> </div> |
| <div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="keyword">private</span>:</div> |
| <div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="comment">// A set of helper functions that transitions an accepted socket to</span></div> |
| <div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="comment">// an SSL connected socket. With the libevent-openssl library, once</span></div> |
| <div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="comment">// we return from the 'accept_callback()' which is scheduled by</span></div> |
| <div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <span class="comment">// 'listen' then we still need to wait for the 'BEV_EVENT_CONNECTED'</span></div> |
| <div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <span class="comment">// state before we know the SSL connection has been established.</span></div> |
| <div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="keyword">struct </span>AcceptRequest</div> |
| <div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  {</div> |
| <div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  AcceptRequest(</div> |
| <div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <span class="keywordtype">int</span> _socket,</div> |
| <div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  evconnlistener* _listener,</div> |
| <div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="keyword">const</span> <a class="code" href="classOption.html">Option<net::IP></a>& _ip)</div> |
| <div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  : peek_event(nullptr),</div> |
| <div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  listener(_listener),</div> |
| <div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <a class="code" href="namespacerouting.html#aee51d4e36a57bab7d6ada56e15467370">socket</a>(_socket),</div> |
| <div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  ip(_ip) {}</div> |
| <div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <span class="keyword">event</span>* peek_event;</div> |
| <div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <a class="code" href="classprocess_1_1Promise.html">Promise<std::shared_ptr<SocketImpl></a>> <a class="code" href="namespacemesos_1_1internal_1_1log_1_1protocol.html#a3b1f8bd7b18c51af9d1f58842950b545">promise</a>;</div> |
| <div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  evconnlistener* listener;</div> |
| <div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordtype">int</span> <a class="code" href="namespacerouting.html#aee51d4e36a57bab7d6ada56e15467370">socket</a>;</div> |
| <div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <a class="code" href="classOption.html">Option<net::IP></a> ip;</div> |
| <div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  };</div> |
| <div class="line"><a name="l00087"></a><span class="lineno"> 87</span> </div> |
| <div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <span class="keyword">struct </span>RecvRequest</div> |
| <div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  {</div> |
| <div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  RecvRequest(<span class="keywordtype">char</span>* _data, <span class="keywordtype">size_t</span> _size)</div> |
| <div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  : data(_data), size(_size) {}</div> |
| <div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  Promise<size_t> <a class="code" href="namespacemesos_1_1internal_1_1log_1_1protocol.html#a3b1f8bd7b18c51af9d1f58842950b545">promise</a>;</div> |
| <div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordtype">char</span>* data;</div> |
| <div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="keywordtype">size_t</span> <a class="code" href="namespaceos_1_1stat.html#aac17a91dd3f91341b8c4021025e89b04">size</a>;</div> |
| <div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  };</div> |
| <div class="line"><a name="l00096"></a><span class="lineno"> 96</span> </div> |
| <div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="keyword">struct </span>SendRequest</div> |
| <div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  {</div> |
| <div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  SendRequest(<span class="keywordtype">size_t</span> _size)</div> |
| <div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  : size(_size) {}</div> |
| <div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  Promise<size_t> <a class="code" href="namespacemesos_1_1internal_1_1log_1_1protocol.html#a3b1f8bd7b18c51af9d1f58842950b545">promise</a>;</div> |
| <div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keywordtype">size_t</span> <a class="code" href="namespaceos_1_1stat.html#aac17a91dd3f91341b8c4021025e89b04">size</a>;</div> |
| <div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  };</div> |
| <div class="line"><a name="l00104"></a><span class="lineno"> 104</span> </div> |
| <div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <span class="keyword">struct </span>ConnectRequest</div> |
| <div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  {</div> |
| <div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  Promise<Nothing> <a class="code" href="namespacemesos_1_1internal_1_1log_1_1protocol.html#a3b1f8bd7b18c51af9d1f58842950b545">promise</a>;</div> |
| <div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  };</div> |
| <div class="line"><a name="l00109"></a><span class="lineno"> 109</span> </div> |
| <div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="comment">// This is a private constructor used by the accept helper</span></div> |
| <div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  <span class="comment">// functions.</span></div> |
| <div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <a class="code" href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#acada5b553dea2903f2744b26a464f98a">LibeventSSLSocketImpl</a>(</div> |
| <div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  <span class="keywordtype">int</span> _s,</div> |
| <div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  bufferevent* bev,</div> |
| <div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <a class="code" href="classOption.html">Option<std::string></a>&& peer_hostname);</div> |
| <div class="line"><a name="l00116"></a><span class="lineno"> 116</span> </div> |
| <div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="comment">// This is called when the equivalent of 'accept' returns. The role</span></div> |
| <div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="comment">// of this function is to set up the SSL object and bev. If we</span></div> |
| <div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <span class="comment">// support both SSL and non-SSL traffic simultaneously then we first</span></div> |
| <div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  <span class="comment">// wait for data to be ready and test the hello handshake to</span></div> |
| <div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="comment">// disambiguate between the kinds of traffic.</span></div> |
| <div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="keywordtype">void</span> accept_callback(AcceptRequest* <a class="code" href="namespaceprocess_1_1http.html#ad8f400b5e54038df7e5662ec35da05fa">request</a>);</div> |
| <div class="line"><a name="l00123"></a><span class="lineno"> 123</span> </div> |
| <div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="comment">// This is the continuation of 'accept_callback' that handles an SSL</span></div> |
| <div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <span class="comment">// connection.</span></div> |
| <div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> accept_SSL_callback(AcceptRequest* <a class="code" href="namespaceprocess_1_1http.html#ad8f400b5e54038df7e5662ec35da05fa">request</a>);</div> |
| <div class="line"><a name="l00127"></a><span class="lineno"> 127</span> </div> |
| <div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="comment">// This function peeks at the data on an accepted socket to see if</span></div> |
| <div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="comment">// there is an SSL handshake or not. It then dispatches to the</span></div> |
| <div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="comment">// SSL handling function or creates a non-SSL socket.</span></div> |
| <div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> peek_callback(evutil_socket_t fd, <span class="keywordtype">short</span> what, <span class="keywordtype">void</span>* arg);</div> |
| <div class="line"><a name="l00132"></a><span class="lineno"> 132</span> </div> |
| <div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="comment">// The following are function pairs of static functions to member</span></div> |
| <div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <span class="comment">// functions. The static functions test and hold the weak pointer to</span></div> |
| <div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="comment">// the socket before calling the member functions. This protects</span></div> |
| <div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="comment">// against the socket being destroyed before the event loop calls</span></div> |
| <div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="comment">// the callbacks.</span></div> |
| <div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> recv_callback(bufferevent* bev, <span class="keywordtype">void</span>* arg);</div> |
| <div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordtype">void</span> recv_callback();</div> |
| <div class="line"><a name="l00140"></a><span class="lineno"> 140</span> </div> |
| <div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> send_callback(bufferevent* bev, <span class="keywordtype">void</span>* arg);</div> |
| <div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="keywordtype">void</span> send_callback();</div> |
| <div class="line"><a name="l00143"></a><span class="lineno"> 143</span> </div> |
| <div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keyword">static</span> <span class="keywordtype">void</span> event_callback(bufferevent* bev, <span class="keywordtype">short</span> events, <span class="keywordtype">void</span>* arg);</div> |
| <div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="keywordtype">void</span> event_callback(<span class="keywordtype">short</span> events);</div> |
| <div class="line"><a name="l00146"></a><span class="lineno"> 146</span> </div> |
| <div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  bufferevent* bev;</div> |
| <div class="line"><a name="l00148"></a><span class="lineno"> 148</span> </div> |
| <div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  evconnlistener* listener;</div> |
| <div class="line"><a name="l00150"></a><span class="lineno"> 150</span> </div> |
| <div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="comment">// Protects the following instance variables.</span></div> |
| <div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  std::atomic_flag lock = ATOMIC_FLAG_INIT;</div> |
| <div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  Owned<RecvRequest> recv_request;</div> |
| <div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  Owned<SendRequest> send_request;</div> |
| <div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  Owned<ConnectRequest> connect_request;</div> |
| <div class="line"><a name="l00156"></a><span class="lineno"> 156</span> </div> |
| <div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  <span class="comment">// Indicates whether or not an EOF has been received on this socket.</span></div> |
| <div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <span class="comment">// Our accesses to this member are not synchronized because they all</span></div> |
| <div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <span class="comment">// occur within the event loop, which runs on a single thread.</span></div> |
| <div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  <span class="keywordtype">bool</span> received_eof = <span class="keyword">false</span>;</div> |
| <div class="line"><a name="l00161"></a><span class="lineno"> 161</span> </div> |
| <div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  <span class="comment">// This is a weak pointer to 'this', i.e., ourselves, this class</span></div> |
| <div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  <span class="comment">// instance. We need this for our event loop callbacks because it's</span></div> |
| <div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  <span class="comment">// possible that we'll actually want to cleanup this socket impl</span></div> |
| <div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  <span class="comment">// before the event loop callback gets executed ... and we'll check</span></div> |
| <div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  <span class="comment">// in each event loop callback whether or not this weak_ptr is valid</span></div> |
| <div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  <span class="comment">// by attempting to upgrade it to shared_ptr. It is the</span></div> |
| <div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  <span class="comment">// responsibility of the event loop through the deferred lambda in</span></div> |
| <div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="comment">// the destructor to clean up this pointer.</span></div> |
| <div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  <span class="comment">// 1) It is a 'weak_ptr' as opposed to a 'shared_ptr' because we</span></div> |
| <div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="comment">// want to test whether the object is still around from within the</span></div> |
| <div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  <span class="comment">// event loop. If it was a 'shared_ptr' then we would be</span></div> |
| <div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  <span class="comment">// contributing to the lifetime of the object and would no longer be</span></div> |
| <div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="comment">// able to test the lifetime correctly.</span></div> |
| <div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <span class="comment">// 2) This is a pointer to a 'weak_ptr' so that we can pass this</span></div> |
| <div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="comment">// through to the event loop through the C-interface. We need access</span></div> |
| <div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="comment">// to the 'weak_ptr' from outside the object (in the event loop) to</span></div> |
| <div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="comment">// test if the object is still alive. By maintaining this 'weak_ptr'</span></div> |
| <div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="comment">// on the heap we can be sure it is safe to access from the</span></div> |
| <div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <span class="comment">// event loop until it is destroyed.</span></div> |
| <div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  std::weak_ptr<LibeventSSLSocketImpl>* event_loop_handle;</div> |
| <div class="line"><a name="l00182"></a><span class="lineno"> 182</span> </div> |
| <div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  <span class="comment">// This queue stores accepted sockets that are considered connected</span></div> |
| <div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  <span class="comment">// (either the SSL handshake has completed or the socket has been</span></div> |
| <div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  <span class="comment">// downgraded). The 'accept()' call returns sockets from this queue.</span></div> |
| <div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  <span class="comment">// We wrap the socket in a 'Future' so that we can pass failures or</span></div> |
| <div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  <span class="comment">// discards through.</span></div> |
| <div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  Queue<Future<std::shared_ptr<SocketImpl>>> accept_queue;</div> |
| <div class="line"><a name="l00189"></a><span class="lineno"> 189</span> </div> |
| <div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  <a class="code" href="classOption.html">Option<std::string></a> peer_hostname;</div> |
| <div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  <a class="code" href="classOption.html">Option<net::IP></a> peer_ip;</div> |
| <div class="line"><a name="l00192"></a><span class="lineno"> 192</span> };</div> |
| <div class="line"><a name="l00193"></a><span class="lineno"> 193</span> </div> |
| <div class="line"><a name="l00194"></a><span class="lineno"> 194</span> } <span class="comment">// namespace internal {</span></div> |
| <div class="line"><a name="l00195"></a><span class="lineno"> 195</span> } <span class="comment">// namespace network {</span></div> |
| <div class="line"><a name="l00196"></a><span class="lineno"> 196</span> } <span class="comment">// namespace process {</span></div> |
| <div class="line"><a name="l00197"></a><span class="lineno"> 197</span> </div> |
| <div class="line"><a name="l00198"></a><span class="lineno"> 198</span> <span class="preprocessor">#endif // __LIBEVENT_SSL_SOCKET_HPP__</span></div> |
| <div class="ttc" id="classOption_html"><div class="ttname"><a href="classOption.html">Option< net::IP ></a></div></div> |
| <div class="ttc" id="namespaceprocess_1_1http_html_ad8f400b5e54038df7e5662ec35da05fa"><div class="ttname"><a href="namespaceprocess_1_1http.html#ad8f400b5e54038df7e5662ec35da05fa">process::http::request</a></div><div class="ttdeci">Future< Response > request(const Request &request, bool streamedResponse=false)</div><div class="ttdoc">Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...</div></div> |
| <div class="ttc" id="classTry_html"><div class="ttname"><a href="classTry.html">Try</a></div><div class="ttdef"><b>Definition:</b> try.hpp:34</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1SocketImpl_html_a303670cfc45c0e1a564fec0532320804"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#a303670cfc45c0e1a564fec0532320804">process::network::internal::SocketImpl::s</a></div><div class="ttdeci">int_fd s</div><div class="ttdef"><b>Definition:</b> socket.hpp:229</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1SocketImpl_html_ab1b898c86d5d9d449a65381c2b1d74f5"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#ab1b898c86d5d9d449a65381c2b1d74f5">process::network::internal::SocketImpl::Kind</a></div><div class="ttdeci">Kind</div><div class="ttdoc">Available kinds of implementations. </div><div class="ttdef"><b>Definition:</b> socket.hpp:64</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a5dd3f53871f2152a0092a222ff63a778"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a5dd3f53871f2152a0092a222ff63a778">process::network::internal::LibeventSSLSocketImpl::accept</a></div><div class="ttdeci">Future< std::shared_ptr< SocketImpl > > accept() override</div><div class="ttdoc">Returns an implementation corresponding to the next pending connection for the listening socket...</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a4ee00c94cb838618b65c5f231e7c367a"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a4ee00c94cb838618b65c5f231e7c367a">process::network::internal::LibeventSSLSocketImpl::connect</a></div><div class="ttdeci">Future< Nothing > connect(const Address &address) override</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1Address_html"><div class="ttname"><a href="classprocess_1_1network_1_1Address.html">process::network::Address</a></div><div class="ttdef"><b>Definition:</b> address.hpp:59</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a03be9e1fa4bf9b0e48ca60c9ca7f360a"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a03be9e1fa4bf9b0e48ca60c9ca7f360a">process::network::internal::LibeventSSLSocketImpl::create</a></div><div class="ttdeci">static Try< std::shared_ptr< SocketImpl > > create(int s)</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a107ac49390f671b4cd5d180e5bddb4ad"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a107ac49390f671b4cd5d180e5bddb4ad">process::network::internal::LibeventSSLSocketImpl::listen</a></div><div class="ttdeci">Try< Nothing > listen(int backlog) override</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1SocketImpl_html_a2289c8b4a10fae48e88518019c900c5a"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1SocketImpl.html#a2289c8b4a10fae48e88518019c900c5a">process::network::internal::SocketImpl::address</a></div><div class="ttdeci">Try< Address > address() const </div><div class="ttdoc">Returns the Address with the assigned ip and assigned port. </div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a94cb94e04c583bc9ee9df66c7a4684cf"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a94cb94e04c583bc9ee9df66c7a4684cf">process::network::internal::LibeventSSLSocketImpl::shutdown</a></div><div class="ttdeci">Try< Nothing > shutdown(int how) override</div><div class="ttdoc">Shuts down the socket. </div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_ad0ecd3ed460c9cf93b32e4d68b0107e7"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#ad0ecd3ed460c9cf93b32e4d68b0107e7">process::network::internal::LibeventSSLSocketImpl::kind</a></div><div class="ttdeci">SocketImpl::Kind kind() const override</div><div class="ttdef"><b>Definition:</b> libevent_ssl_socket.hpp:50</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1SocketImpl_html"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1SocketImpl.html">process::network::internal::SocketImpl</a></div><div class="ttdoc">Implementation interface for a Socket. </div><div class="ttdef"><b>Definition:</b> socket.hpp:55</div></div> |
| <div class="ttc" id="classprocess_1_1Promise_html"><div class="ttname"><a href="classprocess_1_1Promise.html">process::Promise</a></div><div class="ttdef"><b>Definition:</b> future.hpp:72</div></div> |
| <div class="ttc" id="libprocess_2include_2process_2socket_8hpp_html"><div class="ttname"><a href="libprocess_2include_2process_2socket_8hpp.html">socket.hpp</a></div></div> |
| <div class="ttc" id="namespacemesos_1_1internal_1_1log_1_1protocol_html_a3b1f8bd7b18c51af9d1f58842950b545"><div class="ttname"><a href="namespacemesos_1_1internal_1_1log_1_1protocol.html#a3b1f8bd7b18c51af9d1f58842950b545">mesos::internal::log::protocol::promise</a></div><div class="ttdeci">Protocol< PromiseRequest, PromiseResponse > promise</div></div> |
| <div class="ttc" id="namespaceos_1_1stat_html_aac17a91dd3f91341b8c4021025e89b04"><div class="ttname"><a href="namespaceos_1_1stat.html#aac17a91dd3f91341b8c4021025e89b04">os::stat::size</a></div><div class="ttdeci">Try< Bytes > size(const std::string &path, const FollowSymlink follow=FOLLOW_SYMLINK)</div><div class="ttdef"><b>Definition:</b> stat.hpp:88</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_ad2077833906c7d37189588ff67b43a20"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#ad2077833906c7d37189588ff67b43a20">process::network::internal::LibeventSSLSocketImpl::~LibeventSSLSocketImpl</a></div><div class="ttdeci">~LibeventSSLSocketImpl() override</div></div> |
| <div class="ttc" id="namespaceos_html_ae19e4161a51b86a1f330f3bf1dc75389"><div class="ttname"><a href="namespaceos.html#ae19e4161a51b86a1f330f3bf1dc75389">os::process</a></div><div class="ttdeci">Result< Process > process(pid_t pid)</div><div class="ttdef"><b>Definition:</b> freebsd.hpp:30</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html">process::network::internal::LibeventSSLSocketImpl</a></div><div class="ttdef"><b>Definition:</b> libevent_ssl_socket.hpp:32</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_acada5b553dea2903f2744b26a464f98a"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#acada5b553dea2903f2744b26a464f98a">process::network::internal::LibeventSSLSocketImpl::LibeventSSLSocketImpl</a></div><div class="ttdeci">LibeventSSLSocketImpl(int _s)</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a3ee2460274ef43b0665de263b08e3539"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a3ee2460274ef43b0665de263b08e3539">process::network::internal::LibeventSSLSocketImpl::sendfile</a></div><div class="ttdeci">Future< size_t > sendfile(int_fd fd, off_t offset, size_t size) override</div></div> |
| <div class="ttc" id="namespacerouting_html_aee51d4e36a57bab7d6ada56e15467370"><div class="ttname"><a href="namespacerouting.html#aee51d4e36a57bab7d6ada56e15467370">routing::socket</a></div><div class="ttdeci">Try< Netlink< struct nl_sock > > socket(int protocol=NETLINK_ROUTE)</div><div class="ttdef"><b>Definition:</b> internal.hpp:91</div></div> |
| <div class="ttc" id="int__fd_8hpp_html_aea4dbda01c90455f158ffa9b924c2f07"><div class="ttname"><a href="int__fd_8hpp.html#aea4dbda01c90455f158ffa9b924c2f07">int_fd</a></div><div class="ttdeci">int int_fd</div><div class="ttdef"><b>Definition:</b> int_fd.hpp:35</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a0585a14478590e525165a418df7beb3a"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a0585a14478590e525165a418df7beb3a">process::network::internal::LibeventSSLSocketImpl::initialize</a></div><div class="ttdeci">void initialize()</div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a6c91fd87e95efe9c12fe77e02bf306da"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a6c91fd87e95efe9c12fe77e02bf306da">process::network::internal::LibeventSSLSocketImpl::send</a></div><div class="ttdeci">Future< size_t > send(const char *data, size_t size) override</div></div> |
| <div class="ttc" id="queue_8hpp_html"><div class="ttname"><a href="queue_8hpp.html">queue.hpp</a></div></div> |
| <div class="ttc" id="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl_html_a25118017aa15a1ee25039e69fdfd8ea4"><div class="ttname"><a href="classprocess_1_1network_1_1internal_1_1LibeventSSLSocketImpl.html#a25118017aa15a1ee25039e69fdfd8ea4">process::network::internal::LibeventSSLSocketImpl::recv</a></div><div class="ttdeci">Future< size_t > recv(char *data, size_t size) override</div></div> |
| <div class="ttc" id="classprocess_1_1Future_html"><div class="ttname"><a href="classprocess_1_1Future.html">process::Future< Nothing ></a></div></div> |
| </div><!-- fragment --></div><!-- contents --> |
| <!-- start footer part --> |
| <hr class="footer"/><address class="footer"><small> |
| Generated by  <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/> |
| </a> 1.8.5 |
| </small></address> |
| </body> |
| </html> |