Current File : //usr/share/doc/dbus/api/dbus-resources_8c_source.html
<!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"/>
<title>D-Bus: dbus-resources.c Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">D-Bus
   &#160;<span id="projectnumber">1.8.20</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">dbus-resources.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: &quot;gnu&quot;; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-resources.c Resource tracking/limits</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2003  Red Hat Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00010"></a>00010 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00011"></a>00011 <span class="comment"> * (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00016"></a>00016 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> * </span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00019"></a>00019 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;dbus/dbus-resources.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;dbus/dbus-internals.h&gt;</span>
<a name="l00027"></a>00027 
<a name="l00054"></a><a class="code" href="structDBusCounter.html">00054</a> <span class="keyword">struct </span><a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a>
<a name="l00055"></a>00055 {
<a name="l00056"></a><a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0">00056</a>   <span class="keywordtype">int</span> <a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a>;  
<a name="l00058"></a><a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e">00058</a>   <span class="keywordtype">long</span> <a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>;       
<a name="l00059"></a><a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823">00059</a>   <span class="keywordtype">long</span> <a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>;    
<a name="l00061"></a>00061 <span class="preprocessor">#ifdef DBUS_ENABLE_STATS</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>  <span class="keywordtype">long</span> peak_size_value;     
<a name="l00063"></a>00063   <span class="keywordtype">long</span> peak_unix_fd_value;  
<a name="l00064"></a>00064 <span class="preprocessor">#endif</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span>
<a name="l00066"></a><a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064">00066</a>   <span class="keywordtype">long</span> <a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064" title="call notify function when crossing this size value">notify_size_guard_value</a>;    
<a name="l00067"></a><a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c">00067</a>   <span class="keywordtype">long</span> <a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c" title="call notify function when crossing this unix fd value">notify_unix_fd_guard_value</a>; 
<a name="l00069"></a><a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8">00069</a>   DBusCounterNotifyFunction <a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8" title="notify function">notify_function</a>; 
<a name="l00070"></a><a class="code" href="structDBusCounter.html#a592288b6cf62431b3a26aaa6d7c3fb05">00070</a>   <span class="keywordtype">void</span> *<a class="code" href="structDBusCounter.html#a592288b6cf62431b3a26aaa6d7c3fb05" title="data for notify function">notify_data</a>; 
<a name="l00071"></a><a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17">00071</a>   <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> <a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a> : 1; 
<a name="l00072"></a><a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced">00072</a>   <a class="code" href="structDBusRMutex.html">DBusRMutex</a> *<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>;    
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074   <span class="comment">/* end of resource limits internals docs */</span>
<a name="l00076"></a>00076 
<a name="l00088"></a>00088 <a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a>*
<a name="l00089"></a><a class="code" href="group__DBusResources.html#ga9911dd8fa020299a2b517251ea0be399">00089</a> <a class="code" href="group__DBusResources.html#ga9911dd8fa020299a2b517251ea0be399" title="Creates a new DBusCounter.">_dbus_counter_new</a> (<span class="keywordtype">void</span>)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091   <a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   counter = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a>, 1);
<a name="l00094"></a>00094   <span class="keywordflow">if</span> (counter == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00095"></a>00095     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00096"></a>00096 
<a name="l00097"></a>00097   counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> = 1;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099   <a class="code" href="group__DBusThreadsInternals.html#ga191deedb97c76fae82bdbc8e1559a849" title="Creates a new mutex or creates a no-op mutex if threads are not initialized.">_dbus_rmutex_new_at_location</a> (&amp;counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00100"></a>00100   <span class="keywordflow">if</span> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00101"></a>00101   {
<a name="l00102"></a>00102     <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (counter);
<a name="l00103"></a>00103     counter = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00104"></a>00104   }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106   <span class="keywordflow">return</span> counter;
<a name="l00107"></a>00107 }
<a name="l00108"></a>00108 
<a name="l00115"></a>00115 <a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *
<a name="l00116"></a><a class="code" href="group__DBusResources.html#gae93240c77bfb66642453518c9bb90bc4">00116</a> <a class="code" href="group__DBusResources.html#gae93240c77bfb66642453518c9bb90bc4" title="Increments refcount of the counter.">_dbus_counter_ref</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120   _dbus_assert (counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> &gt; 0);
<a name="l00121"></a>00121   
<a name="l00122"></a>00122   counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> += 1;
<a name="l00123"></a>00123 
<a name="l00124"></a>00124   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="keywordflow">return</span> counter;
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128 
<a name="l00135"></a>00135 <span class="keywordtype">void</span>
<a name="l00136"></a><a class="code" href="group__DBusResources.html#ga48d9b53d1a395ab3c4f1846ca569ef3f">00136</a> <a class="code" href="group__DBusResources.html#ga48d9b53d1a395ab3c4f1846ca569ef3f" title="Decrements refcount of the counter and possibly finalizes the counter.">_dbus_counter_unref</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138   <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> last_ref = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00139"></a>00139 
<a name="l00140"></a>00140   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00141"></a>00141 
<a name="l00142"></a>00142   _dbus_assert (counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> &gt; 0);
<a name="l00143"></a>00143 
<a name="l00144"></a>00144   counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> -= 1;
<a name="l00145"></a>00145   last_ref = (counter-&gt;<a class="code" href="structDBusCounter.html#a42ef245097a0b221b58bf200a0a187b0" title="reference count">refcount</a> == 0);
<a name="l00146"></a>00146 
<a name="l00147"></a>00147   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00148"></a>00148 
<a name="l00149"></a>00149   <span class="keywordflow">if</span> (last_ref)
<a name="l00150"></a>00150     {
<a name="l00151"></a>00151       <a class="code" href="group__DBusThreadsInternals.html#gae1c95a3f47bcc78d32fc0a5a8ed37c91" title="Frees a DBusRMutex; does nothing if passed a NULL pointer.">_dbus_rmutex_free_at_location</a> (&amp;counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00152"></a>00152       <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (counter);
<a name="l00153"></a>00153     }
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 
<a name="l00166"></a>00166 <span class="keywordtype">void</span>
<a name="l00167"></a><a class="code" href="group__DBusResources.html#gae37410c196947675c2a222a7979e9dee">00167</a> <a class="code" href="group__DBusResources.html#gae37410c196947675c2a222a7979e9dee" title="Adjusts the value of the size counter by the given delta which may be positive or negative...">_dbus_counter_adjust_size</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter,
<a name="l00168"></a>00168                            <span class="keywordtype">long</span>         delta)
<a name="l00169"></a>00169 {
<a name="l00170"></a>00170   <span class="keywordtype">long</span> old = 0;
<a name="l00171"></a>00171 
<a name="l00172"></a>00172   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00173"></a>00173 
<a name="l00174"></a>00174   old = counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>;
<a name="l00175"></a>00175 
<a name="l00176"></a>00176   counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a> += delta;
<a name="l00177"></a>00177 
<a name="l00178"></a>00178 <span class="preprocessor">#ifdef DBUS_ENABLE_STATS</span>
<a name="l00179"></a>00179 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (counter-&gt;peak_size_value &lt; counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>)
<a name="l00180"></a>00180     counter-&gt;peak_size_value = counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>;
<a name="l00181"></a>00181 <span class="preprocessor">#endif</span>
<a name="l00182"></a>00182 <span class="preprocessor"></span>
<a name="l00183"></a>00183 <span class="preprocessor">#if 0</span>
<a name="l00184"></a>00184 <span class="preprocessor"></span>  _dbus_verbose (<span class="stringliteral">&quot;Adjusting counter %ld by %ld = %ld\n&quot;</span>,
<a name="l00185"></a>00185                  old, delta, counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>);
<a name="l00186"></a>00186 <span class="preprocessor">#endif</span>
<a name="l00187"></a>00187 <span class="preprocessor"></span>
<a name="l00188"></a>00188   <span class="keywordflow">if</span> (counter-&gt;<a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8" title="notify function">notify_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> &amp;&amp;
<a name="l00189"></a>00189       ((old &lt; counter-&gt;notify_size_guard_value &amp;&amp;
<a name="l00190"></a>00190         counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a> &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064" title="call notify function when crossing this size value">notify_size_guard_value</a>) ||
<a name="l00191"></a>00191        (old &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064" title="call notify function when crossing this size value">notify_size_guard_value</a> &amp;&amp;
<a name="l00192"></a>00192         counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a> &lt; counter-&gt;<a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064" title="call notify function when crossing this size value">notify_size_guard_value</a>)))
<a name="l00193"></a>00193     counter-&gt;<a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00194"></a>00194 
<a name="l00195"></a>00195   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197 
<a name="l00206"></a>00206 <span class="keywordtype">void</span>
<a name="l00207"></a><a class="code" href="group__DBusResources.html#gab8c0e970e0c3b4696ba06723639d8239">00207</a> <a class="code" href="group__DBusResources.html#gab8c0e970e0c3b4696ba06723639d8239" title="Calls the notify function from _dbus_counter_set_notify(), if that function has been specified and th...">_dbus_counter_notify</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00208"></a>00208 {
<a name="l00209"></a>00209   DBusCounterNotifyFunction notify_function = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00210"></a>00210   <span class="keywordtype">void</span> *notify_data = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00213"></a>00213   <span class="keywordflow">if</span> (counter-&gt;<a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a>)
<a name="l00214"></a>00214     {
<a name="l00215"></a>00215       counter-&gt;<a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00216"></a>00216       notify_function = counter-&gt;<a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8" title="notify function">notify_function</a>;
<a name="l00217"></a>00217       notify_data = counter-&gt;<a class="code" href="structDBusCounter.html#a592288b6cf62431b3a26aaa6d7c3fb05" title="data for notify function">notify_data</a>;
<a name="l00218"></a>00218     }
<a name="l00219"></a>00219   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00220"></a>00220 
<a name="l00221"></a>00221   <span class="keywordflow">if</span> (notify_function != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00222"></a>00222     (* notify_function) (counter, notify_data);
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 
<a name="l00235"></a>00235 <span class="keywordtype">void</span>
<a name="l00236"></a><a class="code" href="group__DBusResources.html#ga7d9411d27b337289ab5648beb148cde6">00236</a> <a class="code" href="group__DBusResources.html#ga7d9411d27b337289ab5648beb148cde6" title="Adjusts the value of the unix fd counter by the given delta which may be positive or negative...">_dbus_counter_adjust_unix_fd</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter,
<a name="l00237"></a>00237                               <span class="keywordtype">long</span>         delta)
<a name="l00238"></a>00238 {
<a name="l00239"></a>00239   <span class="keywordtype">long</span> old = 0;
<a name="l00240"></a>00240 
<a name="l00241"></a>00241   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00242"></a>00242 
<a name="l00243"></a>00243   old = counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>;
<a name="l00244"></a>00244   
<a name="l00245"></a>00245   counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a> += delta;
<a name="l00246"></a>00246 
<a name="l00247"></a>00247 <span class="preprocessor">#ifdef DBUS_ENABLE_STATS</span>
<a name="l00248"></a>00248 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (counter-&gt;peak_unix_fd_value &lt; counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>)
<a name="l00249"></a>00249     counter-&gt;peak_unix_fd_value = counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>;
<a name="l00250"></a>00250 <span class="preprocessor">#endif</span>
<a name="l00251"></a>00251 <span class="preprocessor"></span>
<a name="l00252"></a>00252 <span class="preprocessor">#if 0</span>
<a name="l00253"></a>00253 <span class="preprocessor"></span>  _dbus_verbose (<span class="stringliteral">&quot;Adjusting counter %ld by %ld = %ld\n&quot;</span>,
<a name="l00254"></a>00254                  old, delta, counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>);
<a name="l00255"></a>00255 <span class="preprocessor">#endif</span>
<a name="l00256"></a>00256 <span class="preprocessor"></span>  
<a name="l00257"></a>00257   <span class="keywordflow">if</span> (counter-&gt;<a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8" title="notify function">notify_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> &amp;&amp;
<a name="l00258"></a>00258       ((old &lt; counter-&gt;notify_unix_fd_guard_value &amp;&amp;
<a name="l00259"></a>00259         counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a> &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c" title="call notify function when crossing this unix fd value">notify_unix_fd_guard_value</a>) ||
<a name="l00260"></a>00260        (old &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c" title="call notify function when crossing this unix fd value">notify_unix_fd_guard_value</a> &amp;&amp;
<a name="l00261"></a>00261         counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a> &lt; counter-&gt;<a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c" title="call notify function when crossing this unix fd value">notify_unix_fd_guard_value</a>)))
<a name="l00262"></a>00262     counter-&gt;<a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00263"></a>00263 
<a name="l00264"></a>00264   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 
<a name="l00273"></a>00273 <span class="keywordtype">long</span>
<a name="l00274"></a><a class="code" href="group__DBusResources.html#ga49de078fb626aff30f273933ad5c8b2a">00274</a> <a class="code" href="group__DBusResources.html#ga49de078fb626aff30f273933ad5c8b2a" title="Gets the current value of the size counter.">_dbus_counter_get_size_value</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00275"></a>00275 {
<a name="l00276"></a>00276   <span class="keywordflow">return</span> counter-&gt;<a class="code" href="structDBusCounter.html#aadf8f12634aab55166d694320c545f8e" title="current size counter value">size_value</a>;
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 
<a name="l00285"></a>00285 <span class="keywordtype">long</span>
<a name="l00286"></a><a class="code" href="group__DBusResources.html#ga25b2d12b9dc4d3525df2b8401f4ce56d">00286</a> <a class="code" href="group__DBusResources.html#ga25b2d12b9dc4d3525df2b8401f4ce56d" title="Gets the current value of the unix fd counter.">_dbus_counter_get_unix_fd_value</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288   <span class="keywordflow">return</span> counter-&gt;<a class="code" href="structDBusCounter.html#af23298e36b579cc511f00d03ce3ff823" title="current unix fd counter value">unix_fd_value</a>;
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290 
<a name="l00302"></a>00302 <span class="keywordtype">void</span>
<a name="l00303"></a><a class="code" href="group__DBusResources.html#ga240bddfe384b32a8703a328a638219e1">00303</a> <a class="code" href="group__DBusResources.html#ga240bddfe384b32a8703a328a638219e1" title="Sets the notify function for this counter; the notify function is called whenever the counter&#39;s value...">_dbus_counter_set_notify</a> (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a>               *counter,
<a name="l00304"></a>00304                           <span class="keywordtype">long</span>                       size_guard_value,
<a name="l00305"></a>00305                           <span class="keywordtype">long</span>                       unix_fd_guard_value,
<a name="l00306"></a>00306                           DBusCounterNotifyFunction  <span class="keyword">function</span>,
<a name="l00307"></a>00307                           <span class="keywordtype">void</span>                      *user_data)
<a name="l00308"></a>00308 {
<a name="l00309"></a>00309   <a class="code" href="group__DBusThreadsInternals.html#gaeb20c411a096aaf067918eb574f121d5" title="Locks a mutex.">_dbus_rmutex_lock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00310"></a>00310   counter-&gt;<a class="code" href="structDBusCounter.html#af73ade097f3dfad1035361867b9f7064" title="call notify function when crossing this size value">notify_size_guard_value</a> = size_guard_value;
<a name="l00311"></a>00311   counter-&gt;<a class="code" href="structDBusCounter.html#a85157c4d3c445e41f58dc6941b23814c" title="call notify function when crossing this unix fd value">notify_unix_fd_guard_value</a> = unix_fd_guard_value;
<a name="l00312"></a>00312   counter-&gt;<a class="code" href="structDBusCounter.html#a626238ea91d2cf0c93a6eb958f7199b8" title="notify function">notify_function</a> = <span class="keyword">function</span>;
<a name="l00313"></a>00313   counter-&gt;<a class="code" href="structDBusCounter.html#a592288b6cf62431b3a26aaa6d7c3fb05" title="data for notify function">notify_data</a> = user_data;
<a name="l00314"></a>00314   counter-&gt;<a class="code" href="structDBusCounter.html#a9c26dcd74f700959b0b920ec2bf1fd17" title="TRUE if the guard value has been crossed.">notify_pending</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00315"></a>00315   <a class="code" href="group__DBusThreadsInternals.html#ga5946b9a5ea3e12a81a798b575b45c62f" title="Unlocks a mutex.">_dbus_rmutex_unlock</a> (counter-&gt;<a class="code" href="structDBusCounter.html#ae99efa36b9a41e9c103f454a102bfced" title="Lock on the entire DBusCounter.">mutex</a>);
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317 
<a name="l00318"></a>00318 <span class="preprocessor">#ifdef DBUS_ENABLE_STATS</span>
<a name="l00319"></a>00319 <span class="preprocessor"></span><span class="keywordtype">long</span>
<a name="l00320"></a>00320 _dbus_counter_get_peak_size_value (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00321"></a>00321 {
<a name="l00322"></a>00322   <span class="keywordflow">return</span> counter-&gt;peak_size_value;
<a name="l00323"></a>00323 }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325 <span class="keywordtype">long</span>
<a name="l00326"></a>00326 _dbus_counter_get_peak_unix_fd_value (<a class="code" href="structDBusCounter.html" title="Internals of DBusCounter.">DBusCounter</a> *counter)
<a name="l00327"></a>00327 {
<a name="l00328"></a>00328   <span class="keywordflow">return</span> counter-&gt;peak_unix_fd_value;
<a name="l00329"></a>00329 }
<a name="l00330"></a>00330 <span class="preprocessor">#endif</span>
<a name="l00331"></a>00331 <span class="preprocessor"></span>  <span class="comment">/* end of resource limits exported API */</span>
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:31 for D-Bus by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>