diff options
Diffstat (limited to 'docs/doxygen/nel/a03366.html')
-rw-r--r-- | docs/doxygen/nel/a03366.html | 849 |
1 files changed, 849 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a03366.html b/docs/doxygen/nel/a03366.html new file mode 100644 index 00000000..312fcd7c --- /dev/null +++ b/docs/doxygen/nel/a03366.html @@ -0,0 +1,849 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLNET::CServerReceiveTask class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLNET::CServerReceiveTask Class Reference</h1><code>#include <<a class="el" href="a05513.html">buf_server.h</a>></code> +<p> +<p>Inheritance diagram for NLNET::CServerReceiveTask: +<p><center><img src="a03366.png" usemap="#NLNET::CServerReceiveTask_map" border="0" alt=""></center> +<map name="NLNET::CServerReceiveTask_map"> +<area href="a02187.html" alt="NLMISC::IRunnable" shape="rect" coords="0,0,178,24"> +<area href="a02771.html" alt="NLNET::CServerTask" shape="rect" coords="188,0,366,24"> +</map> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Code of receiving threads for servers. Note: the methods locations in the classes do not correspond to the threads where they are executed, but to the data they use. +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00410">410</a> of file <a class="el" href="a05513.html">buf_server.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska0">addNewSocket</a> (<a class="el" href="a02303.html">TSockId</a> sockid)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Add a new connection into this thread (mutexed on _Connections). <a href="#NLNET_1_1CServerReceiveTaska0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska1">addToRemoveSet</a> (<a class="el" href="a02303.html">TSockId</a> sockid)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska2">clearClosedConnections</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Delete all connections referenced in the remove list (mutexed on _RemoveSet and on _Connections). <a href="#NLNET_1_1CServerReceiveTaska2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska3">CServerReceiveTask</a> (<a class="el" href="a02302.html">CBufServer</a> *server)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NLNET_1_1CServerReceiveTaska3"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02187.html#NLMISC_1_1IRunnablePosa0">getName</a> (std::string &result) const </td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a15">uint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska5">numberOfConnections</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of connections handled by the thread (mutexed on _Connections). <a href="#NLNET_1_1CServerReceiveTaska5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02771.html#NLNET_1_1CServerTaska0">requireExit</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Tells the task to exit. <a href="#NLNET_1_1CServerTaska0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska7">run</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Run. <a href="#NLNET_1_1CServerReceiveTaska7"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02302.html">CBufServer</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaska8">server</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Access to the server. <a href="#NLNET_1_1CServerReceiveTaska8"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Data Fields</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02771.html#NLNET_1_1CServerTasko0">NbLoop</a></td></tr> + +<tr><td colspan=2><br><h2>Protected Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02771.html#NLNET_1_1CServerTaskb1">exitRequired</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns true if the <a class="el" href="a02771.html#NLNET_1_1CServerTaska0">requireExit()</a> has been called. <a href="#NLNET_1_1CServerTaskb1"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>NLMISC::CSynchronized< <a class="el" href="a05379.html#a82">CConnections</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr0">_Connections</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>NLMISC::CSynchronized< <a class="el" href="a05379.html#a82">CConnections</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr1">_RemoveSet</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02302.html">CBufServer</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">_Server</a></td></tr> + +<tr><td colspan=2><br><h2>Friends</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>class </td><td class="memItemRight" valign=bottom><a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskn0">CBufServer</a></td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska3" doxytag="NLNET::CServerReceiveTask::CServerReceiveTask" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLNET::CServerReceiveTask::CServerReceiveTask </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02302.html">CBufServer</a> * </td> + <td class="mdname1" valign="top" nowrap> <em>server</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00415">415</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00487">_Connections</a>, and <a class="el" href="a05513.html#l00490">_RemoveSet</a>. +<p> +<div class="fragment"><pre>00415 : <a class="code" href="a02771.html#NLNET_1_1CServerTaskb0">CServerTask</a>(), <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">_Server</a>(server), <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr0">_Connections</a>(<span class="stringliteral">"CServerReceiveTask::_Connections"</span>), <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr1">_RemoveSet</a>(<span class="stringliteral">"CServerReceiveTask::_RemoveSet"</span>) {} +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska0" doxytag="NLNET::CServerReceiveTask::addNewSocket" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLNET::CServerReceiveTask::addNewSocket </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02303.html">TSockId</a> </td> + <td class="mdname1" valign="top" nowrap> <em>sockid</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Add a new connection into this thread (mutexed on _Connections). +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00432">432</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00487">_Connections</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a05511.html#l00042">NLNET::TSockId</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00958">NLNET::CBufServer::addNewThread()</a>, and <a class="el" href="a05512.html#l00866">NLNET::CBufServer::dispatchNewSocket()</a>. +<p> +<div class="fragment"><pre>00433 { +00434 <span class="comment">//nlnettrace( "CServerReceiveTask::addNewSocket" );</span> +00435 <a class="code" href="a04199.html#a6">nlassert</a>( sockid != InvalidSockId ); +00436 { +00437 NLMISC::CSynchronized<CConnections>::CAccessor connectionssync( &_Connections ); +00438 connectionssync.value().insert( sockid ); +00439 } +00440 <span class="comment">// POLL3</span> +00441 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska1" doxytag="NLNET::CServerReceiveTask::addToRemoveSet" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLNET::CServerReceiveTask::addToRemoveSet </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02303.html">TSockId</a> </td> + <td class="mdname1" valign="top" nowrap> <em>sockid</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Add connection to the remove set (mutexed on _RemoveSet) Note: you must not call this method within a mutual exclusion on _Connections, or there will be a deadlock (see clearClosedConnection()) +<p> +Definition at line <a class="el" href="a05513.html#l00449">449</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00490">_RemoveSet</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05515.html#l00040">nlnettrace</a>, and <a class="el" href="a05511.html#l00042">NLNET::TSockId</a>. +<p> +<div class="fragment"><pre>00450 { +00451 <a class="code" href="a04092.html#a0">nlnettrace</a>( <span class="stringliteral">"CServerReceiveTask::addToRemoveSet"</span> ); +00452 <a class="code" href="a04199.html#a6">nlassert</a>( sockid != InvalidSockId ); +00453 { +00454 <span class="comment">// Three possibilities :</span> +00455 <span class="comment">// - The value is inserted into the set.</span> +00456 <span class="comment">// - The value is already present in the set.</span> +00457 <span class="comment">// - The set is locked by a receive thread which is removing the closed connections.</span> +00458 <span class="comment">// When the set gets unlocked, it is empty so the value is inserted. It means the</span> +00459 <span class="comment">// value could be already in the set before it was cleared.</span> +00460 <span class="comment">// Note: with a fonction such as tryAcquire(), we could avoid to enter the mutex</span> +00461 <span class="comment">// when it is already locked</span> +00462 <span class="comment">// See clearClosedConnections().</span> +00463 NLMISC::CSynchronized<CConnections>::CAccessor removesetsync( &_RemoveSet ); +00464 removesetsync.value().insert( sockid ); +00465 <span class="comment">//nldebug( "LNETL1: ic: %p - RemoveSet.size(): %d", ic, removesetsync.value().size() );</span> +00466 } +00467 <span class="preprocessor">#ifdef NL_OS_UNIX</span> +00468 <span class="preprocessor"></span> wakeUp(); +00469 <span class="preprocessor">#endif</span> +00470 <span class="preprocessor"></span> } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska2" doxytag="NLNET::CServerReceiveTask::clearClosedConnections" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLNET::CServerReceiveTask::clearClosedConnections </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Delete all connections referenced in the remove list (mutexed on _RemoveSet and on _Connections). +<p> + +<p> +Definition at line <a class="el" href="a05512.html#l01191">1191</a> of file <a class="el" href="a05512.html">buf_server.cpp</a>. +<p> +References <a class="el" href="a05513.html#l00487">_Connections</a>, <a class="el" href="a05513.html#l00490">_RemoveSet</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, and <a class="el" href="a05511.html#l00042">NLNET::TSockId</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00987">run()</a>. +<p> +<div class="fragment"><pre>01192 { +01193 CConnections::iterator ic; +01194 { +01195 NLMISC::CSynchronized<CConnections>::CAccessor removesetsync( &_RemoveSet ); +01196 { +01197 <span class="keywordflow">if</span> ( ! removesetsync.value().empty() ) +01198 { +01199 <span class="comment">// Delete closed connections</span> +01200 NLMISC::CSynchronized<CConnections>::CAccessor connectionssync( &_Connections ); +01201 <span class="keywordflow">for</span> ( ic=removesetsync.value().begin(); ic!=removesetsync.value().end(); ++ic ) +01202 { +01203 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: Removing a connection"</span> ); +01204 +01205 <a class="code" href="a05379.html#a74">TSockId</a> sid = (*ic); +01206 +01207 <span class="comment">// Remove from the connection list</span> +01208 connectionssync.value().erase( *ic ); +01209 +01210 <span class="comment">// Delete the socket object</span> +01211 <span class="keyword">delete</span> sid; +01212 } +01213 <span class="comment">// Clear remove list</span> +01214 removesetsync.value().clear(); +01215 } +01216 } +01217 } +01218 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerTaskb1" doxytag="NLNET::CServerReceiveTask::exitRequired" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLNET::CServerTask::exitRequired </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, protected, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Returns true if the <a class="el" href="a02771.html#NLNET_1_1CServerTaska0">requireExit()</a> has been called. +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00071">71</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00080">NLNET::CServerTask::_ExitRequired</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00987">run()</a>, and <a class="el" href="a05512.html#l00779">NLNET::CListenTask::run()</a>. +<p> +<div class="fragment"><pre>00071 { <span class="keywordflow">return</span> _ExitRequired; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1IRunnablePosa0" doxytag="NLNET::CServerReceiveTask::getName" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual void NLMISC::IRunnable::getName </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>result</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, virtual, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Reimplemented in <a class="el" href="a02220.html#NL3D_1_1CAsyncFileManager3D_1_1CMeshLoada1">NL3D::CAsyncFileManager3D::CMeshLoad</a>, <a class="el" href="a02218.html#NL3D_1_1CAsyncFileManager3D_1_1CIGLoada1">NL3D::CAsyncFileManager3D::CIGLoad</a>, <a class="el" href="a02219.html#NL3D_1_1CAsyncFileManager3D_1_1CIGLoadUsera1">NL3D::CAsyncFileManager3D::CIGLoadUser</a>, <a class="el" href="a02222.html#NL3D_1_1CAsyncFileManager3D_1_1CTextureLoada1">NL3D::CAsyncFileManager3D::CTextureLoad</a>, <a class="el" href="a03752.html#NL3D_1_1CZoneLoadingTaska1">NL3D::CZoneLoadingTask</a>, <a class="el" href="a02593.html#NLPACS_1_1CGlobalRetriever_1_1CLrLoadera1">NLPACS::CGlobalRetriever::CLrLoader</a>, <a class="el" href="a02223.html#NLMISC_1_1CAsyncFileManager_1_1CFileLoada1">NLMISC::CAsyncFileManager::CFileLoad</a>, <a class="el" href="a02224.html#NLMISC_1_1CAsyncFileManager_1_1CMultipleFileLoada1">NLMISC::CAsyncFileManager::CMultipleFileLoad</a>, and <a class="el" href="a02225.html#NLMISC_1_1CAsyncFileManager_1_1CSignala1">NLMISC::CAsyncFileManager::CSignal</a>. +<p> +Definition at line <a class="el" href="a06535.html#l00074">74</a> of file <a class="el" href="a06535.html">thread.h</a>. +<p> +Referenced by <a class="el" href="a06485.html#l00061">NLMISC::CTaskManager::run()</a>. +<p> +<div class="fragment"><pre>00075 { +00076 result = <span class="stringliteral">"NoName"</span>; +00077 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska5" doxytag="NLNET::CServerReceiveTask::numberOfConnections" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a15">uint</a> NLNET::CServerReceiveTask::numberOfConnections </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Returns the number of connections handled by the thread (mutexed on _Connections). +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00421">421</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00487">_Connections</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00866">NLNET::CBufServer::dispatchNewSocket()</a>. +<p> +<div class="fragment"><pre>00422 { +00423 <a class="code" href="a04558.html#a15">uint</a> nb; +00424 { +00425 NLMISC::CSynchronized<CConnections>::CAccessor connectionssync( &_Connections ); +00426 nb = connectionssync.value().size(); +00427 } +00428 <span class="keywordflow">return</span> nb; +00429 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerTaska0" doxytag="NLNET::CServerReceiveTask::requireExit" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLNET::CServerTask::requireExit </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Tells the task to exit. +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00056">56</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +References <a class="el" href="a05513.html#l00080">NLNET::CServerTask::_ExitRequired</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00166">NLNET::CBufServer::~CBufServer()</a>. +<p> +<div class="fragment"><pre>00056 { _ExitRequired = <span class="keyword">true</span>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska7" doxytag="NLNET::CServerReceiveTask::run" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLNET::CServerReceiveTask::run </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Run. +<p> + +<p> +<dl compact><dt><b><a class="el" href="todo.html#_todo000032">Todo:</a></b></dt><dd>cado: the error code is not properly retrieved</dd></dl> + +<p> +Implements <a class="el" href="a02187.html#NLMISC_1_1IRunnablePosa1">NLMISC::IRunnable</a>. +<p> +Definition at line <a class="el" href="a05512.html#l00987">987</a> of file <a class="el" href="a05512.html">buf_server.cpp</a>. +<p> +References <a class="el" href="a05513.html#l00487">_Connections</a>, <a class="el" href="a05514.html#l00329">NLNET::CBufSock::asString()</a>, <a class="el" href="a05511.html#l00056">NLNET::CFifoAccessor</a>, <a class="el" href="a05512.html#l01191">clearClosedConnections()</a>, <a class="el" href="a05513.html#l00071">NLNET::CServerTask::exitRequired()</a>, <a class="el" href="a05515.html#l00368">NLNET::CServerBufSock::fillSockIdAndEventType()</a>, <a class="el" href="a05510.html#l00036">NLNET::NbNetworkTask</a>, <a class="el" href="a05512.html#l00049">NLNET::NbServerReceiveTask</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05515.html#l00040">nlnettrace</a>, <a class="el" href="a05586.html#l00073">NLMISC::nlSleep()</a>, <a class="el" href="a05515.html#l00308">NLNET::CNonBlockingBufSock::receivedBuffer()</a>, <a class="el" href="a05514.html#l00386">NLNET::CNonBlockingBufSock::receivePart()</a>, <a class="el" href="a05511.html#l00154">NLNET::CBufNetBase::receiveQueue()</a>, <a class="el" href="a05646.html#l01119">res</a>, <a class="el" href="a05511.html#l00203">NLNET::CBufNetBase::setDataAvailableFlag()</a>, <a class="el" href="a05511.html#l00042">NLNET::TSockId</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00988 { +00989 <a class="code" href="a05379.html#a8">NbNetworkTask</a>++; +00990 <a class="code" href="a05379.html#a10">NbServerReceiveTask</a>++; +00991 <a class="code" href="a04092.html#a0">nlnettrace</a>( <span class="stringliteral">"CServerReceiveTask::run"</span> ); +00992 +00993 SOCKET descmax; +00994 fd_set readers; +00995 +00996 <span class="comment">// Time-out value for select (it can be long because we do not do any thing else in this thread)</span> +00997 timeval tv; +00998 <span class="preprocessor">#if defined NL_OS_UNIX</span> +00999 <span class="preprocessor"></span> <span class="comment">// POLL7</span> +01000 nice( 2 ); +01001 <span class="preprocessor">#endif // NL_OS_UNIX</span> +01002 <span class="preprocessor"></span> +01003 <span class="comment">// Copy of _Connections</span> +01004 vector<TSockId> connections_copy; +01005 +01006 <span class="keywordflow">while</span> ( ! <a class="code" href="a02771.html#NLNET_1_1CServerTaskb1">exitRequired</a>() ) +01007 { +01008 <span class="comment">// 1. Remove closed connections</span> +01009 <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaska2">clearClosedConnections</a>(); +01010 +01011 <span class="comment">// POLL8</span> +01012 +01013 <span class="comment">// 2-SELECT-VERSION : select() on the sockets handled in the present thread</span> +01014 +01015 descmax = 0; +01016 FD_ZERO( &readers ); +01017 <span class="keywordtype">bool</span> skip; +01018 <span class="keywordtype">bool</span> alldisconnected = <span class="keyword">true</span>; +01019 CConnections::iterator ipb; +01020 { +01021 <span class="comment">// Lock _Connections</span> +01022 CSynchronized<CConnections>::CAccessor connectionssync( &_Connections ); +01023 +01024 <span class="comment">// Prepare to avoid select if there is no connection</span> +01025 skip = connectionssync.value().empty(); +01026 +01027 <span class="comment">// Fill the select array and copy _Connections</span> +01028 connections_copy.clear(); +01029 <span class="keywordflow">for</span> ( ipb=connectionssync.value().begin(); ipb!=connectionssync.value().end(); ++ipb ) +01030 { +01031 <span class="keywordflow">if</span> ( (*ipb)->Sock->connected() ) <span class="comment">// exclude disconnected sockets that are not deleted</span> +01032 { +01033 alldisconnected = <span class="keyword">false</span>; +01034 <span class="comment">// Copy _Connections element</span> +01035 connections_copy.push_back( *ipb ); +01036 +01037 <span class="comment">// Add socket descriptor to the select array</span> +01038 FD_SET( (*ipb)->Sock->descriptor(), &readers ); +01039 +01040 <span class="comment">// Calculate descmax for select</span> +01041 <span class="keywordflow">if</span> ( (*ipb)->Sock->descriptor() > descmax ) +01042 { +01043 descmax = (*ipb)->Sock->descriptor(); +01044 } +01045 } +01046 } +01047 +01048 <span class="preprocessor">#ifdef NL_OS_UNIX</span> +01049 <span class="preprocessor"></span> <span class="comment">// Add the wake-up pipe into the select array</span> +01050 FD_SET( _WakeUpPipeHandle[PipeRead], &readers ); +01051 <span class="keywordflow">if</span> ( _WakeUpPipeHandle[PipeRead]>descmax ) +01052 { +01053 descmax = _WakeUpPipeHandle[PipeRead]; +01054 } +01055 <span class="preprocessor">#endif</span> +01056 <span class="preprocessor"></span> +01057 <span class="comment">// Unlock _Connections, use connections_copy instead</span> +01058 } +01059 +01060 <span class="preprocessor">#ifndef NL_OS_UNIX</span> +01061 <span class="preprocessor"></span> <span class="comment">// Avoid select if there is no connection (Windows only)</span> +01062 <span class="keywordflow">if</span> ( skip || alldisconnected ) +01063 { +01064 <a class="code" href="a05378.html#a256">nlSleep</a>( 1 ); <span class="comment">// nice</span> +01065 <span class="keywordflow">continue</span>; +01066 } +01067 <span class="preprocessor">#endif</span> +01068 <span class="preprocessor"></span> +01069 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span> +01070 <span class="preprocessor"></span> tv.tv_sec = 0; <span class="comment">// short time because the newly added connections can't be added to the select fd_set</span> +01071 tv.tv_usec = 10000; <span class="comment">// NEW: set to 500ms because otherwise new connections handling are too slow</span> +01072 <span class="preprocessor">#elif defined NL_OS_UNIX</span> +01073 <span class="preprocessor"></span> <span class="comment">// POLL7</span> +01074 tv.tv_sec = 3600; <span class="comment">// 1 hour (=> 1 select every 3.6 second for 1000 connections)</span> +01075 tv.tv_usec = 0; +01076 <span class="preprocessor">#endif // NL_OS_WINDOWS</span> +01077 <span class="preprocessor"></span> +01078 <span class="comment">// Call select</span> +01079 <span class="keywordtype">int</span> <a class="code" href="a04223.html#a643">res</a> = ::select( descmax+1, &readers, NULL, NULL, &tv ); +01080 +01081 <span class="comment">// POLL9</span> +01082 +01083 <span class="comment">// 3. Test the result</span> +01084 <span class="keywordflow">switch</span> ( <a class="code" href="a04223.html#a643">res</a> ) +01085 { +01086 <span class="keywordflow">case</span> 0 : <span class="keywordflow">continue</span>; <span class="comment">// time-out expired, no results</span> +01087 +01089 <span class="keywordflow">case</span> -1 : +01090 <span class="comment">// we'll ignore message (Interrupted system call) caused by a CTRL-C</span> +01091 <span class="comment">/*if (CSock::getLastError() == 4)</span> +01092 <span class="comment"> {</span> +01093 <span class="comment"> nldebug ("LNETL1: Select failed (in receive thread): %s (code %u) but IGNORED", CSock::errorString( CSock::getLastError() ).c_str(), CSock::getLastError());</span> +01094 <span class="comment"> continue;</span> +01095 <span class="comment"> }*/</span> +01096 <span class="comment">//nlerror( "LNETL1: Select failed (in receive thread): %s (code %u)", CSock::errorString( CSock::getLastError() ).c_str(), CSock::getLastError() );</span> +01097 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: Select failed (in receive thread): %s (code %u)"</span>, CSock::errorString( CSock::getLastError() ).c_str(), CSock::getLastError() ); +01098 <span class="keywordflow">goto</span> end; +01099 } +01100 +01101 <span class="comment">// 4. Get results</span> +01102 +01103 vector<TSockId>::iterator ic; +01104 <span class="keywordflow">for</span> ( ic=connections_copy.begin(); ic!=connections_copy.end(); ++ic ) +01105 { +01106 <span class="keywordflow">if</span> ( FD_ISSET( (*ic)->Sock->descriptor(), &readers ) != 0 ) +01107 { +01108 CServerBufSock *serverbufsock = static_cast<CServerBufSock*>(static_cast<CBufSock*>(*ic)); +01109 <span class="keywordflow">try</span> +01110 { +01111 <span class="comment">// 4. Receive data</span> +01112 <span class="keywordflow">if</span> ( serverbufsock->receivePart( <span class="keyword">sizeof</span>(TSockId) + 1 ) ) <span class="comment">// +1 for the event type</span> +01113 { +01114 serverbufsock->fillSockIdAndEventType( *ic ); +01115 +01116 <span class="comment">// Push message into receive queue</span> +01117 <span class="comment">//uint32 bufsize;</span> +01118 <span class="comment">//sint32 mbsize;</span> +01119 { +01120 <span class="comment">//nldebug( "RCV: Acquiring the receive queue... ");</span> +01121 <a class="code" href="a05379.html#a79">CFifoAccessor</a> recvfifo( &<a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">_Server</a>->receiveQueue() ); +01122 <span class="comment">//nldebug( "RCV: Acquired, pushing the received buffer... ");</span> +01123 recvfifo.value().push( serverbufsock->receivedBuffer() ); +01124 +01125 <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">_Server</a>->setDataAvailableFlag( <span class="keyword">true</span> ); +01126 +01127 <span class="comment">//nldebug( "RCV: Pushed, releasing the receive queue..." );</span> +01128 <span class="comment">//recvfifo.value().display();</span> +01129 <span class="comment">//bufsize = serverbufsock->receivedBuffer().size();</span> +01130 <span class="comment">//mbsize = recvfifo.value().size() / 1048576;</span> +01131 } +01132 <span class="comment">//nldebug( "RCV: Released." );</span> +01133 <span class="comment">/*if ( mbsize > 1 )</span> +01134 <span class="comment"> {</span> +01135 <span class="comment"> nlwarning( "The receive queue size exceeds %d MB", mbsize );</span> +01136 <span class="comment"> }*/</span> +01137 <span class="comment">/*</span> +01138 <span class="comment"> // Statistics</span> +01139 <span class="comment"> {</span> +01140 <span class="comment"> CSynchronized<uint32>::CAccessor syncbpi ( &_Server->syncBytesPushedIn() );</span> +01141 <span class="comment"> syncbpi.value() += bufsize;</span> +01142 <span class="comment"> }</span> +01143 <span class="comment"> */</span> +01144 } +01145 } +01146 <span class="keywordflow">catch</span> ( ESocketConnectionClosed& ) +01147 { +01148 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: Connection %s closed"</span>, serverbufsock->asString().c_str() ); +01149 <span class="comment">// The socket went to _Connected=false when throwing the exception</span> +01150 } +01151 <span class="keywordflow">catch</span> ( ESocket& ) +01152 { +01153 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: Connection %s broken"</span>, serverbufsock->asString().c_str() ); +01154 (*ic)->Sock->disconnect(); +01155 } +01156 <span class="comment">/*</span> +01157 <span class="comment">#ifdef NL_OS_UNIX</span> +01158 <span class="comment"> skip = true; // don't check _WakeUpPipeHandle (yes, check it to read any written byte)</span> +01159 <span class="comment">#endif</span> +01160 <span class="comment"></span> +01161 <span class="comment">*/</span> +01162 } +01163 } +01164 +01165 <span class="preprocessor">#ifdef NL_OS_UNIX</span> +01166 <span class="preprocessor"></span> <span class="comment">// Test wake-up pipe</span> +01167 <span class="keywordflow">if</span> ( (!skip) && (FD_ISSET( _WakeUpPipeHandle[PipeRead], &readers )) ) +01168 { +01169 <a class="code" href="a04558.html#a7">uint8</a> b; +01170 <span class="keywordflow">if</span> ( read( _WakeUpPipeHandle[PipeRead], &b, 1 ) == -1 ) <span class="comment">// we were woken-up by the wake-up pipe</span> +01171 { +01172 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: In CServerReceiveTask::run(): read() failed"</span> ); +01173 } +01174 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"LNETL1: Receive thread select woken-up"</span> ); +01175 } +01176 <span class="preprocessor">#endif</span> +01177 <span class="preprocessor"></span> +01178 <a class="code" href="a02771.html#NLNET_1_1CServerTasko0">NbLoop</a>++; +01179 } +01180 end: +01181 <a class="code" href="a04092.html#a0">nlnettrace</a>( <span class="stringliteral">"Exiting CServerReceiveTask::run"</span> ); +01182 <a class="code" href="a05379.html#a10">NbServerReceiveTask</a>--; +01183 <a class="code" href="a05379.html#a8">NbNetworkTask</a>--; +01184 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaska8" doxytag="NLNET::CServerReceiveTask::server" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02302.html">CBufServer</a>* NLNET::CServerReceiveTask::server </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Access to the server. +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00476">476</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +<div class="fragment"><pre>00476 { <span class="keywordflow">return</span> <a class="code" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">_Server</a>; } +</pre></div> </td> + </tr> +</table> +<hr><h2>Friends And Related Function Documentation</h2> +<a class="anchor" name="NLNET_1_1CServerReceiveTaskn0" doxytag="NLNET::CServerReceiveTask::CBufServer" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> friend class <a class="el" href="a02302.html">CBufServer</a><code> [friend]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00478">478</a> of file <a class="el" href="a05513.html">buf_server.h</a>. </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLNET_1_1CServerReceiveTaskr0" doxytag="NLNET::CServerReceiveTask::_Connections" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CSynchronized<<a class="el" href="a05379.html#a82">CConnections</a>> <a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr0">NLNET::CServerReceiveTask::_Connections</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00487">487</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +Referenced by <a class="el" href="a05513.html#l00432">addNewSocket()</a>, <a class="el" href="a05512.html#l01191">clearClosedConnections()</a>, <a class="el" href="a05513.html#l00415">CServerReceiveTask()</a>, <a class="el" href="a05512.html#l00251">NLNET::CBufServer::disconnect()</a>, <a class="el" href="a05512.html#l00713">NLNET::CBufServer::displaySendQueueStat()</a>, <a class="el" href="a05512.html#l00660">NLNET::CBufServer::getSendQueueSize()</a>, <a class="el" href="a05513.html#l00421">numberOfConnections()</a>, <a class="el" href="a05512.html#l00987">run()</a>, <a class="el" href="a05512.html#l00299">NLNET::CBufServer::send()</a>, <a class="el" href="a05512.html#l00613">NLNET::CBufServer::update()</a>, and <a class="el" href="a05512.html#l00166">NLNET::CBufServer::~CBufServer()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaskr1" doxytag="NLNET::CServerReceiveTask::_RemoveSet" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CSynchronized<<a class="el" href="a05379.html#a82">CConnections</a>> <a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr1">NLNET::CServerReceiveTask::_RemoveSet</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00490">490</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +Referenced by <a class="el" href="a05513.html#l00449">addToRemoveSet()</a>, <a class="el" href="a05512.html#l01191">clearClosedConnections()</a>, and <a class="el" href="a05513.html#l00415">CServerReceiveTask()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerReceiveTaskr2" doxytag="NLNET::CServerReceiveTask::_Server" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02302.html">CBufServer</a>* <a class="el" href="a03366.html#NLNET_1_1CServerReceiveTaskr2">NLNET::CServerReceiveTask::_Server</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00482">482</a> of file <a class="el" href="a05513.html">buf_server.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLNET_1_1CServerTasko0" doxytag="NLNET::CServerReceiveTask::NbLoop" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02771.html#NLNET_1_1CServerTasko0">NLNET::CServerTask::NbLoop</a><code> [inherited]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05513.html#l00063">63</a> of file <a class="el" href="a05513.html">buf_server.h</a>. +<p> +Referenced by <a class="el" href="a05512.html#l00695">NLNET::CBufServer::displayThreadStat()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a05513.html">buf_server.h</a><li><a class="el" href="a05512.html">buf_server.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 14:03:40 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |