<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://bugs.maemo.com/skins/common/feed.css?207"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Documentation/Maemo 5 Developer Guide/DBus/D-Bus Server Design Issues - Revision history</title>
		<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.15.5-7</generator>
		<lastBuildDate>Sat, 04 Apr 2026 10:13:25 GMT</lastBuildDate>
		<item>
			<title>amigadave:&amp;#32;add example links</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=38334&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=38334&amp;oldid=prev</guid>
			<description>&lt;p&gt;add example links&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:22, 6 September 2010&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Close all standard I/O file descriptors (and preferably also files), so that if the terminal device closes (user logs out), it does not cause &amp;lt;code&amp;gt;SIGPIPE&amp;lt;/code&amp;gt; signals to the daemon the next time it accesses the file descriptors (by mistake or intentionally because of &amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;). Reopening the file descriptors is also possible, so that they are connected to a device, which just ignore all operations (like /dev/null that is used with daemon).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Close all standard I/O file descriptors (and preferably also files), so that if the terminal device closes (user logs out), it does not cause &amp;lt;code&amp;gt;SIGPIPE&amp;lt;/code&amp;gt; signals to the daemon the next time it accesses the file descriptors (by mistake or intentionally because of &amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;). Reopening the file descriptors is also possible, so that they are connected to a device, which just ignore all operations (like /dev/null that is used with daemon).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The daemon function allows to select whether or not a change of the directory is wanted and to close the open file descriptors. This utilizes in the servers of this example in the following way: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The daemon function allows to select whether or not a change of the directory is wanted and to close the open file descriptors. This utilizes in the servers of this example in the following way: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[http://vcs.maemo.org/svn/maemoexamples/trunk/glib-dbus-sync/server.c &lt;/ins&gt;glib-dbus-sync/server.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This definition is available to the user inside the Makefile: glib-dbus-sync/Makefile&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This definition is available to the user inside the Makefile: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[http://vcs.maemo.org/svn/maemoexamples/trunk/glib-dbus-sync/Makefile &lt;/ins&gt;glib-dbus-sync/Makefile&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 154:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 154:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is the intelligent use of print-out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) helps. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called &amp;lt;code&amp;gt;dbg&amp;lt;/code&amp;gt; is used, which expands to &amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt; when the server is built as a non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code is generated to format the parameters or to even access them. Extending this idea to support multiple levels of debugging is advisable, as is using different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on the object of the debugging procedure.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is the intelligent use of print-out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) helps. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called &amp;lt;code&amp;gt;dbg&amp;lt;/code&amp;gt; is used, which expands to &amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt; when the server is built as a non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code is generated to format the parameters or to even access them. Extending this idea to support multiple levels of debugging is advisable, as is using different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on the object of the debugging procedure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The &amp;lt;code&amp;gt;dbg&amp;lt;/code&amp;gt; macro utilizes the &amp;lt;code&amp;gt;__func__&amp;lt;/code&amp;gt; symbol, which expands to the function name where the macro is expanded. This is quite useful because the function name does not need to be explicitly added: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The &amp;lt;code&amp;gt;dbg&amp;lt;/code&amp;gt; macro utilizes the &amp;lt;code&amp;gt;__func__&amp;lt;/code&amp;gt; symbol, which expands to the function name where the macro is expanded. This is quite useful because the function name does not need to be explicitly added: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[http://vcs.maemo.org/svn/maemoexamples/trunk/glib-dbus-sync/server.c &lt;/ins&gt;glib-dbus-sync/server.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 171:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 171:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the macro is quite simple, as it looks and acts like a regular printf-formatting function (&amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt; included): glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the macro is quite simple, as it looks and acts like a regular printf-formatting function (&amp;lt;code&amp;gt;g_print&amp;lt;/code&amp;gt; included): &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[http://vcs.maemo.org/svn/maemoexamples/trunk/glib-dbus-sync/server.c &lt;/ins&gt;glib-dbus-sync/server.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:25 --&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 06 Sep 2010 12:22:36 GMT</pubDate>			<dc:creator>amigadave</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>amigadave:&amp;#32;use &lt;code&gt;</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=37843&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=37843&amp;oldid=prev</guid>
			<description>&lt;p&gt;use &amp;lt;code&amp;gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 08:53, 17 August 2010&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 84:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 84:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The slightly convoluted way of using grep was necessary to list only those lines of the &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; report, which have ./server in them, and to remove the lines which do not have &amp;lt;code&amp;gt;pts&amp;lt;/code&amp;gt; in them (so that seeing the processes which have no controlling terminals is possible).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The slightly convoluted way of using &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;grep&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;was necessary to list only those lines of the &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; report, which have ./server in them, and to remove the lines which do not have &amp;lt;code&amp;gt;pts&amp;lt;/code&amp;gt; in them (so that seeing the processes which have no controlling terminals is possible).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The client could have been used to test whether the server responds, but the above technique is slightly more general. If the &amp;lt;code&amp;gt;pstree&amp;lt;/code&amp;gt; tool is available, it could be run it with &amp;lt;code&amp;gt;-pu&amp;lt;/code&amp;gt; options to see how the processes relate to each other and that the daemonized server is running directly as a child of &amp;lt;code&amp;gt;init&amp;lt;/code&amp;gt; (which was the objective of the fork).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The client could have been used to test whether the server responds, but the above technique is slightly more general. If the &amp;lt;code&amp;gt;pstree&amp;lt;/code&amp;gt; tool is available, it could be run it with &amp;lt;code&amp;gt;-pu&amp;lt;/code&amp;gt; options to see how the processes relate to each other and that the daemonized server is running directly as a child of &amp;lt;code&amp;gt;init&amp;lt;/code&amp;gt; (which was the objective of the fork).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 152:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 152:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Debugging ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Debugging ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is the intelligent use of print-out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) helps. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called dbg is used, which expands to g_print when the server is built as a non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code is generated to format the parameters or to even access them. Extending this idea to support multiple levels of debugging is advisable, as is using different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on the object of the debugging procedure.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is the intelligent use of print-out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) helps. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;dbg&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;is used, which expands to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;g_print&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;when the server is built as a non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code is generated to format the parameters or to even access them. Extending this idea to support multiple levels of debugging is advisable, as is using different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on the object of the debugging procedure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The dbg macro utilizes the &amp;lt;code&amp;gt;__func__&amp;lt;/code&amp;gt; symbol, which expands to the function name where the macro is expanded. This is quite useful because the function name does not need to be explicitly added: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;dbg&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;macro utilizes the &amp;lt;code&amp;gt;__func__&amp;lt;/code&amp;gt; symbol, which expands to the function name where the macro is expanded. This is quite useful because the function name does not need to be explicitly added: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:26 --&gt;
&lt;/table&gt;</description>
			<pubDate>Tue, 17 Aug 2010 08:53:02 GMT</pubDate>			<dc:creator>amigadave</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>amigadave:&amp;#32;wikify slightly, use &lt;source&gt;</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=37208&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=37208&amp;oldid=prev</guid>
			<description>&lt;p&gt;wikify slightly, use &amp;lt;source&amp;gt;&lt;/p&gt;
&lt;a href=&quot;http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;amp;diff=37208&amp;amp;oldid=29321&quot;&gt;Show changes&lt;/a&gt;</description>
			<pubDate>Thu, 22 Jul 2010 09:51:55 GMT</pubDate>			<dc:creator>amigadave</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>amigadave:&amp;#32;categorise</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=29321&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=29321&amp;oldid=prev</guid>
			<description>&lt;p&gt;categorise&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:06, 12 February 2010&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 186:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 186:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which are using the client code and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. Using Valgrind to help detecting memory leaks (and some other errors) can also be of interest. More information on these topics and examples is available in the [[Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Debugging Guide|Maemo Debugging Guide]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which are using the client code and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. Using Valgrind to help detecting memory leaks (and some other errors) can also be of interest. More information on these topics and examples is available in the [[Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Debugging Guide|Maemo Debugging Guide]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Development]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Documentation]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Fremantle]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:27 --&gt;
&lt;/table&gt;</description>
			<pubDate>Fri, 12 Feb 2010 12:06:56 GMT</pubDate>			<dc:creator>amigadave</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>liox_lang_valid:&amp;#32;/* Debugging */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18218&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18218&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Debugging&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:17, 16 September 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 153:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 153:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Debugging ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Debugging ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is intelligent use of print out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will help&lt;/del&gt;. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called dbg is used, which &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will expand &lt;/del&gt;to g_print&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;when the server is built as non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;generated to format the parameters&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;or to even access them. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;It is advisable to extend &lt;/del&gt;this idea to support multiple levels of debugging, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;and possibly use &lt;/del&gt;different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;what it is that is to be debugged&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The simplest way to debug servers is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;intelligent use of print&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-&lt;/ins&gt;out of events in the code sections that are relevant. Tracing everything that goes on rarely makes sense, but having a reliable and working infrastructure (in code level) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;helps&lt;/ins&gt;. One such mechanism is utilizing various built-in tricks that gcc and cpp provide. In the server example, a macro called dbg is used, which &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;expands &lt;/ins&gt;to g_print when the server is built as &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a &lt;/ins&gt;non-daemonizing version. If the server becomes a daemon, the macro expands to &amp;quot;nothing&amp;quot;, meaning that no code &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;generated to format the parameters or to even access them. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Extending &lt;/ins&gt;this idea to support multiple levels of debugging &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is advisable&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;as is using &lt;/ins&gt;different &amp;quot;subsystem&amp;quot; identifiers, so that a single subsystem can be switched on or off, depending on &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the object of the debugging procedure&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The dbg macro utilizes the __func__ symbol, which expands to the function name where the macro &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;expanded&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, which &lt;/del&gt;is quite useful &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;so that &lt;/del&gt;the function name does not need to be explicitly added: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The dbg macro utilizes the __func__ symbol, which expands to the function name where the macro &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;expanded&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. This &lt;/ins&gt;is quite useful &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;the function name does not need to be explicitly added: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;/* A small macro that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will wrap &lt;/del&gt;g_print and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;expand &lt;/del&gt;to empty when&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;/* A small macro that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;wraps &lt;/ins&gt;g_print and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;expands &lt;/ins&gt;to empty when&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will daemonize&lt;/del&gt;. We use this to add debugging info on&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a &lt;/ins&gt;server &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;daemonizes&lt;/ins&gt;. We use this to add debugging info on&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  the server side, but if server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;daemonized, it does not&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  the server side, but if &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;server &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;daemonized, it does not&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  make sense to even compile the code in.&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp;  make sense to even compile the code in.&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 171:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 171:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the macro is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;then &lt;/del&gt;quite simple, as it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will look &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;act &lt;/del&gt;like a regular printf-formatting function (g_print included): glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the macro is quite simple, as it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;looks &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;acts &lt;/ins&gt;like a regular printf-formatting function (g_print included): glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;nbsp; &amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000000&amp;quot;&amp;gt;dbg&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#FF0000&amp;quot;&amp;gt;&amp;quot;Called (internal value2 is %.3f)&amp;quot;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; obj&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;-&amp;amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;value2&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;);&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;nbsp; &amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000000&amp;quot;&amp;gt;dbg&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#FF0000&amp;quot;&amp;gt;&amp;quot;Called (internal value2 is %.3f)&amp;quot;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; obj&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;-&amp;amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;value2&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;);&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The only small difference here is that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it is not necessary to explicitly add &lt;/del&gt;the trailing newline (&amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;) into each call&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, since &lt;/del&gt;it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be automatically &lt;/del&gt;added.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The only small difference here is that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;adding &lt;/ins&gt;the trailing newline (&amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;explicitly &lt;/ins&gt;into each call &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is not necessary because &lt;/ins&gt;it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;added &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;automatically&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Assuming NO_DAEMON is defined, the macro &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would expand &lt;/del&gt;to the following output when the server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;was &lt;/del&gt;run:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Assuming NO_DAEMON is defined, the macro &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;expands &lt;/ins&gt;to the following output when the server &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;run:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For larger projects, it is advisable to combine __file__, so that tracing multifile programs will become easier.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For larger projects, it is advisable to combine __file__, so that tracing multifile programs will become easier.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;using the client code&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;It can also be of interest to use &lt;/del&gt;Valgrind to help detecting memory leaks (and some other errors). More information on these topics and examples &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;available in the [[Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Debugging Guide|Maemo Debugging Guide]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;using the client code and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Using &lt;/ins&gt;Valgrind to help detecting memory leaks (and some other errors) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can also be of interest&lt;/ins&gt;. More information on these topics and examples &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;available in the [[Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Debugging Guide|Maemo Debugging Guide]]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:27 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 16 Sep 2009 12:17:43 GMT</pubDate>			<dc:creator>liox_lang_valid</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>liox_lang_valid:&amp;#32;/* Supporting Parallel Requests */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18217&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18217&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Supporting Parallel Requests&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:07, 16 September 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 131:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 131:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Supporting Parallel Requests ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Supporting Parallel Requests ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The value object server with delays has one major deficiency: it can only handle one request at a time, while blocking the progress of all the other requests. This &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;a problem&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;if multiple clients use the same server at the same time.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The value object server with delays has one major deficiency: it can only handle one request at a time, while blocking the progress of all the other requests. This &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;a problem if multiple clients use the same server at the same time.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Normally &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;one would add &lt;/del&gt;support for parallel requests by using some kind of multiplexing mechanism right on top of the message delivery mechanism (in this case, libdbus).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Normally support for parallel requests &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is added &lt;/ins&gt;by using some kind of multiplexing mechanism right on top of the message delivery mechanism (in this case, libdbus).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;One can group the &lt;/del&gt;possible solutions around three models:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The &lt;/ins&gt;possible solutions &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can be grouped &lt;/ins&gt;around three models:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Launching a separate thread to handle each request. This &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;might &lt;/del&gt;seem like an easy way out of the problem, but coordinating access to shared resources (object states in this case) between multiple threads is prone to cause synchronization problems, and makes debugging much harder. Also, performance of such an approach &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would depend &lt;/del&gt;on efficient synchronization primitives in the platform (which might not always be available), as well as lightweight thread creation and tear-down capabilities of the platform.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Launching a separate thread to handle each request. This &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can &lt;/ins&gt;seem like an easy way out of the problem, but coordinating access to shared resources (object states in this case) between multiple threads is prone to cause synchronization problems, and makes debugging much harder. Also, performance of such an approach &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;depends &lt;/ins&gt;on efficient synchronization primitives in the platform (which might not always be available), as well as lightweight thread creation and tear-down capabilities of the platform.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Using an event-driven model that supports multiple event sources simultaneously and &amp;quot;wakes up&amp;quot; only when there is an event on any of the event sources. The select and poll (and epoll on Linux) are very often used in these cases. Using them &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;normally &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;require &lt;/del&gt;an application design that is driven by the requirements of the system calls (&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;i.e. it is very difficult to retrofit &lt;/del&gt;them into existing &amp;quot;linear&amp;quot; designs). However, the event-based approach normally outperforms the thread approach, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;there is no need for synchronization (when implemented correctly), and there &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;only &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;one context to switch from the kernel and back (there &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;extra contexts with threads). GLib provides a high-level abstraction on top of the low-level event programming model, in the form of GMainLoop. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;One would use &lt;/del&gt;GIOChannel objects to represent each event source&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and register callbacks that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;triggered on the events.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Using an event-driven model that supports multiple event sources simultaneously and &amp;quot;wakes up&amp;quot; only when there is an event on any of the event sources. The select and poll (and epoll on Linux) are very often used in these cases. Using them normally &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;requires &lt;/ins&gt;an application design that is driven by the requirements of the system calls (&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;which means that retrofitting &lt;/ins&gt;them into existing &amp;quot;linear&amp;quot; designs &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is difficult&lt;/ins&gt;). However, the event-based approach normally outperforms the thread approach, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;there is no need for synchronization (when implemented correctly), and there &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;only one context to switch from the kernel and back (there &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;extra contexts with threads). GLib provides a high-level abstraction on top of the low-level event programming model, in the form of GMainLoop. GIOChannel objects &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are used &lt;/ins&gt;to represent each event source and register callbacks that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;triggered on the events.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Using fork to create a copy of the server process, so that the new copy &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will just handle &lt;/del&gt;one request and then &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;terminate &lt;/del&gt;(or &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;return &lt;/del&gt;to the pool of &amp;quot;servers&amp;quot;). The problem here is the process creation overhead, and the lack of implicit sharing of resources between the processes. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;One would have to arrange a &lt;/del&gt;separate mechanism for synchronization and data sharing between the processes (using shared memory and proper synchronization primitives). In some cases, resource sharing is not actually required, or happens at some lower level (accessing files), so this model &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;should &lt;/del&gt;not be automatically ruled out, even if it seems quite heavy at first. Many static content web servers use this model because of its simplicity (and they do not need to share data between themselves).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Using fork to create a copy of the server process, so that the new copy &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;handles &lt;/ins&gt;one request and then &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;terminates &lt;/ins&gt;(or &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;returns &lt;/ins&gt;to the pool of &amp;quot;servers&amp;quot;). The problem here is the process creation overhead, and the lack of implicit sharing of resources between the processes. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;A &lt;/ins&gt;separate mechanism for synchronization and data sharing between the processes (using shared memory and proper synchronization primitives) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;have to be arranged&lt;/ins&gt;. In some cases, resource sharing is not actually required, or &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;it &lt;/ins&gt;happens at some lower level (accessing files), so this model &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;does &lt;/ins&gt;not &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;need to &lt;/ins&gt;be automatically ruled out, even if it seems quite heavy at first. Many static content web servers use this model because of its simplicity (and they do not need to share data between themselves).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;However, the problem for the slow server lies elsewhere: the GLib/D-Bus wrappers do not support parallel requests directly. Even using the fork model &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;problematic&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, as &lt;/del&gt;there &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;multiple processes accessing the same D-Bus connection. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Also&lt;/del&gt;, this problem is not specific to the slow server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;only&lt;/del&gt;. The same issues &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;encountered when using other high-level frameworks (such as GTK+) whenever they cannot complete something immediately, because not all data is present in the application. In the latter case, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it is normally sufficient to use &lt;/del&gt;the GMainLoop/GIOChannel approach in parallel with GTK+ (&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;it uses GMainLoop internally anyway), but with GLib/D-Bus there is no mechanism which could be used to integrate own multiplexing code (no suitable API exists).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;However, the problem for the slow server lies elsewhere: the GLib/D-Bus wrappers do not support parallel requests directly. Even using the fork model &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;problematic &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;there &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;multiple processes accessing the same D-Bus connection. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Furthermore&lt;/ins&gt;, this problem is not &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;only &lt;/ins&gt;specific to the slow server. The same issues &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;encountered when using other high-level frameworks (such as GTK+) whenever they cannot complete something immediately, because not all data is present in the application. In the latter case, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;using &lt;/ins&gt;the GMainLoop/GIOChannel approach in parallel with GTK+ (&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;it uses GMainLoop internally anyway) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is normally sufficient&lt;/ins&gt;, but with GLib/D-Bus there is no mechanism which could be used to integrate own multiplexing code (no suitable API exists).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this case, the solution &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;picking one of the above models&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;then &lt;/del&gt;using libdbus functions directly. In effect, this &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would require &lt;/del&gt;a complete rewrite of the server, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;forgetting about &lt;/del&gt;the GType implementation&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and possibly creating a light-weight wrapper for integrating libdbus functions into GLib GMainLoop mechanism (but dropping support for GType).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this case, the solution &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;picking one of the above&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-mentioned &lt;/ins&gt;models and using &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;libdbus functions directly. In effect, this &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;requires &lt;/ins&gt;a complete rewrite of the server, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;disregarding &lt;/ins&gt;the GType implementation and possibly creating a light-weight wrapper for integrating libdbus functions into &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;GLib GMainLoop mechanism (but dropping support for GType).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Dropping support for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/del&gt;GType and stub code &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will mean &lt;/del&gt;that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it would be necessary to implement &lt;/del&gt;the introspection support manually and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;dependent on possible API changes in libdbus in the future.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Dropping &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;support for GType and stub code &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;means &lt;/ins&gt;that the introspection support &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;needs to be implemented &lt;/ins&gt;manually and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;that it is &lt;/ins&gt;dependent on &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;possible API changes in libdbus in the future.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Another possible solution &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;to &amp;quot;fake&amp;quot; the completion of client method calls, so that the RPC method &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would complete &lt;/del&gt;immediately&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;but the server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would continue &lt;/del&gt;(using GIOChannel integration) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;processing the request&lt;/del&gt;, until it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;really &lt;/del&gt;completes. The problem in this solution is that it is very difficult to know&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;which client actually issued the original method call&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and how to communicate the final result (or errors) of the method call to the client once it completes. One possible model here &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;using signals to broadcast the end result of the method call, so that the client &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would get &lt;/del&gt;the result at some point (assuming the client is still attached to the message bus). Needless to say, this is quite inelegant and difficult to implement correctly, especially &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;sending signals &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will cause &lt;/del&gt;unnecessary load by waking up all the clients on the bus (even if they are not interested in that particular signal).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Another possible solution &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;to &amp;quot;fake&amp;quot; the completion of client method calls, so that the RPC method &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;completes &lt;/ins&gt;immediately but the server &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;continues processing the request &lt;/ins&gt;(using GIOChannel integration), until it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;actually &lt;/ins&gt;completes. The problem in this solution is that it is very difficult to know which client actually issued the original method call and how to communicate the final result (or errors) of the method call to the client once it completes. One possible model here &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;using signals to broadcast the end result of the method call, so that the client &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;gets &lt;/ins&gt;the result at some point (assuming the client is still attached to the message bus). Needless to say, this is quite inelegant and difficult to implement correctly, especially &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;sending signals &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;causes &lt;/ins&gt;unnecessary load by waking up all the clients on the bus (even if they are not interested in that particular signal).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In short, there is no simple solution that works properly when GLib/D-Bus wrappers are used.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In short, there is no simple solution that works properly when GLib/D-Bus wrappers are used.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:27 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 16 Sep 2009 12:07:23 GMT</pubDate>			<dc:creator>liox_lang_valid</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>liox_lang_valid:&amp;#32;/* Event Loops and Power Consumption */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18212&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18212&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Event Loops and Power Consumption&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 11:12, 16 September 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 91:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 91:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Event Loops and Power Consumption ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Event Loops and Power Consumption ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most modern CPUs (even for desktops and servers) allow multiple levels of power savings to be selected. Each of the levels &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;progressively more power-conservative, but there is always a price involved. The deeper the power saving level required, the more time it normally takes to achieve it, and the more time it also takes to come out of it. In some CPUs, it also requires special sequences of instructions to run, hence taking extra power itself.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most modern CPUs (even for desktops and servers) allow multiple levels of power savings to be selected. Each of the levels &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;progressively more power-conservative, but there is always a price involved. The deeper the power saving level required, the more time it normally takes to achieve it, and the more time it also takes to come out of it. In some CPUs, it also requires special sequences of instructions to run, hence taking extra power itself.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;All this means that changing the power state of the CPU should be avoided whenever possible. Obviously, this is in contrast to the requirement to conserve battery life, so in effect, what is needed is to require the attention of the CPU as rarely as possible.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;All this means that changing the power state of the CPU should be avoided whenever possible. Obviously, this is in contrast to the requirement to conserve battery life, so in effect, what is needed is to require the attention of the CPU as rarely as possible.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;One way at looking the problem field is contrasting event-based and polling-based programming. Code that continuously checks for some status&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and only occasionally performs useful work&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;is clearly keeping the CPU from powering down properly. This model should be avoided at all cost, or at least its use should be restricted to bare minimum, if no other solution is possible.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;One way at looking the problem field is contrasting event-based and polling-based programming. Code that continuously checks for some status and only occasionally performs useful work is clearly keeping the CPU from powering down properly. This model should be avoided at all cost, or at least its use should be restricted to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a &lt;/ins&gt;bare minimum, if no other solution is possible.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In contrast, event-based programming is usually based on the execution of callback functions when something happens, without requiring a separate polling loop. This then leaves the question of how to trigger the callbacks, so that they &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;issued&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;when something happens. Using timer callbacks &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;might &lt;/del&gt;seem like a simple solution, so that it continuously (once per second or more often) checks for status, and then possibly reacts to the change in status. This model is undesirable as well, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;the CPU &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;able to enter into deep sleep modes, but fluctuate between full power and high-power states.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In contrast, event-based programming is usually based on the execution of callback functions when something happens, without requiring a separate polling loop. This then leaves the question of how to trigger the callbacks, so that they &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;issued when something happens. Using timer callbacks &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can &lt;/ins&gt;seem like a simple solution, so that it continuously (once per second or more often) checks for status, and then possibly reacts to the change in status. This model is undesirable as well, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;the CPU &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;not able to enter into deep sleep modes, but fluctuate between full power and high-power states.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most operating system kernels provide a mechanism (or multiple mechanisms) by which a process can be woken up when data is available&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and kept off the running queue of the scheduler &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;otherwise&lt;/del&gt;. The most common mechanism in Linux is based around the select/poll system calls, which are useful when waiting for a change in status for a set of file descriptors. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Since &lt;/del&gt;most of the interesting things in Linux can be represented as a &amp;quot;file&amp;quot; (an object supporting read and write system calls), using select and poll is quite common. However, when writing software that uses GLib (implicitly like in GTK+ or explicitly like in the non-GUI examples in this document), the GMainLoop structure &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;used instead. Internally, it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will use &lt;/del&gt;the event mechanism available on the platform (select/poll/others), but the program &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will need &lt;/del&gt;to register callbacks, start the main loop execution and then just execute the callbacks as they come.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most operating system kernels provide a mechanism (or multiple mechanisms) by which a process can be woken up when data is available and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;otherwise &lt;/ins&gt;kept off the running queue of the scheduler. The most common mechanism in Linux is based around the select/poll system calls, which are useful when waiting for a change in status for a set of file descriptors. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Because &lt;/ins&gt;most of the interesting things in Linux can be represented as a &amp;quot;file&amp;quot; (an object supporting read and write system calls), using select and poll is quite common. However, when writing software that uses GLib (implicitly like in GTK+ or explicitly like in the non-GUI examples in this document), the GMainLoop structure &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;used instead. Internally, it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;uses &lt;/ins&gt;the event mechanism available on the platform (select/poll/others), but the program &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;needs &lt;/ins&gt;to register callbacks, start the main loop execution and then just execute the callbacks as they come.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If there are some file descriptors (network sockets, open files, etc), they can be integrated into the GMainLoop using GIOChannels (&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;please &lt;/del&gt;see the GLib API reference on this).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If there are some file descriptors (network sockets, open files, etc), they can be integrated into the GMainLoop using GIOChannels (see the GLib API reference on this).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This still leaves the question of using timers and callbacks that are triggered by timers. They should be avoided when:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This still leaves the question of using timers and callbacks that are triggered by timers. They should be avoided when:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;You plan to use the &lt;/del&gt;timer at high frequencies (&amp;amp;gt; 1 Hz) for long periods of time (&amp;amp;gt; 5 sec).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The &lt;/ins&gt;timer &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is used &lt;/ins&gt;at high frequencies (&amp;amp;gt; 1 Hz) for long periods of time (&amp;amp;gt; 5 sec).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* There is a mechanism that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will trigger &lt;/del&gt;a callback when something happens, instead of forcing &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;you to poll for the &lt;/del&gt;status &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;manually&amp;quot; &lt;/del&gt;or re-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;execute &lt;/del&gt;a timer callback that does the checking.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* There is a mechanism that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;triggers &lt;/ins&gt;a callback when something happens, instead of forcing &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a manual &lt;/ins&gt;status &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;poll &lt;/ins&gt;or re-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;executing &lt;/ins&gt;a timer callback that does the checking.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As an example, the LibOSSO program (FlashLight) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;that was covered before, will have &lt;/del&gt;to use timers in order to keep the backlight active. However, the timer is very slow (only once every 45 seconds), so this is not a big issue. Also, in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;flashlight&lt;/del&gt;'s defense, the backlight is on all the time, so having a slow timer &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not hurt battery life very much anyway.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As an example, the LibOSSO program (FlashLight) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;has &lt;/ins&gt;to use timers in order to keep the backlight active. However, the timer is very slow (only once every 45 seconds), so this is not a big issue. Also, in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;FlashLight&lt;/ins&gt;'s defense, the backlight is on all the time, so having a slow timer &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;does &lt;/ins&gt;not hurt battery life very much anyway.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Another example could be a long-lasting download operation, which proceeds slowly&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;but steadily. It &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;advisable to consider&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;whether updating a progress bar after each small bit of data is received makes sense (normally it does not). Instead, it is better to keep track of when was the last time when the progress bar was updated, and if enough time has passed since the last time, update the GUI. In some cases, this &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will allow &lt;/del&gt;the CPU to be left in a somewhat lower power state than full-power, and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will allow &lt;/del&gt;it to fall back to sleep more quickly.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Another example could be a long-lasting download operation, which proceeds slowly but steadily. It &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;advisable to consider whether updating a progress bar after each small bit of data is received makes sense (normally it does not). Instead, it is better to keep track of when was the last time when the progress bar was updated, and if enough time has passed since the last time, update the GUI. In some cases, this &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;allows &lt;/ins&gt;the CPU to be left in a somewhat lower power state than full-power, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;allows &lt;/ins&gt;it to fall back to sleep more quickly.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Having multiple separate programs running, each having their own timers, presents another interesting problem. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Since &lt;/del&gt;the timer callback is not precise, at some time the system &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be waking &lt;/del&gt;at a very high frequency, handling each timer separately (the frequency and the number of timers executing in the system is something that cannot be controlled from a single program, but instead is a system-wide issue).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Having multiple separate programs running, each having their own timers, presents another interesting problem. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Because &lt;/ins&gt;the timer callback is not precise, at some time the system &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;wakes &lt;/ins&gt;at a very high frequency, handling each timer separately (the frequency and the number of timers executing in the system is something that cannot be controlled from a single program, but instead is a system-wide issue).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If planning a GUI program, it is fairly easy to avoid contributing to this problem, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;it is possible to get a callback from LibOSSO, which &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will tell &lt;/del&gt;when the program is &amp;quot;on top&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and when it is not visible. When not visible, the GUI does not need to be updated, especially with timer-based progress indicators and such.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If planning a GUI program, it is fairly easy to avoid contributing to this problem, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;it is possible to get a callback from LibOSSO, which &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;tells &lt;/ins&gt;when the program is &amp;quot;on top&amp;quot; and when it is not visible. When not visible, the GUI does not need to be updated, especially with timer-based progress indicators and such.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Since &lt;/del&gt;servers do not have a GUI (and their visibility is not controlled by the window manager), such mechanism does not exist. One possible solution in this case &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would be &lt;/del&gt;avoiding &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;using &lt;/del&gt;timers (or any resources for that matter)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;when the server does not have any active clients. Resources should only be used when there is a client connection&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;or there is a need to actually do something. As soon as it becomes likely that the server &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;used again, the resources should be released (timer callbacks removed, etc.).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Because &lt;/ins&gt;servers do not have a GUI (and their visibility is not controlled by the window manager), such mechanism does not exist. One possible solution in this case &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;avoiding &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the use of &lt;/ins&gt;timers (or any resources for that matter) when the server does not have any active clients. Resources should only be used when there is a client connection or &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;when &lt;/ins&gt;there is a need to actually do something. As soon as it becomes likely that the server &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;not used again, the resources should be released (timer callbacks removed, etc.).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If possible, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;one should &lt;/del&gt;try and utilize the D-Bus signals available on the system bus (or even the hardware state structure via LibOSSO) to throttle down activity based on the conditions in the environment. Even if making a non-GUI server, the system shutdown signals should be listened to&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, as &lt;/del&gt;they &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;tell the process to shutdown gracefully.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If possible, try and utilize the D-Bus signals available on the system bus (or even the hardware state structure via LibOSSO) to throttle down activity based on the conditions in the environment. Even if making a non-GUI server, the system shutdown signals should be listened to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;they tell the process to shutdown gracefully.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;All in all, designing for a dynamic low-powered environment is not always simple. Four simple rules &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;hold for most cases &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(all of them being important)&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;All in all, designing for a dynamic low-powered environment is not always simple. Four simple &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;but important &lt;/ins&gt;rules hold &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;true &lt;/ins&gt;for most cases:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Avoid doing extra work when possible.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Avoid doing extra work when possible.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 127:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 127:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Keep only those resources allocated that you need to get the work done.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Keep only those resources allocated that you need to get the work done.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For GUI programs, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;one will have to take into account &lt;/del&gt;the &amp;quot;graphical side&amp;quot; of things as well. Making a GUI that is very conservative in its power usage &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will&lt;/del&gt;, most of the time, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;very simple, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;provide &lt;/del&gt;little excitement to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;users &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;might &lt;/del&gt;even look quite ugly. The priorities for the programmer &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;might &lt;/del&gt;lie in a different direction.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For GUI programs, the &amp;quot;graphical side&amp;quot; of things &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;has to be taken into account &lt;/ins&gt;as well. Making a GUI that is very conservative in its power usage &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is&lt;/ins&gt;, most of the time, very simple, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;but it provides &lt;/ins&gt;little excitement to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the user &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can &lt;/ins&gt;even look quite ugly. The priorities for the programmer &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can &lt;/ins&gt;lie in a different direction.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Supporting Parallel Requests ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Supporting Parallel Requests ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:27 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 16 Sep 2009 11:12:38 GMT</pubDate>			<dc:creator>liox_lang_valid</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>liox_lang_valid:&amp;#32;/* Daemonization */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18211&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18211&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Daemonization&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 10:43, 16 September 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Daemonization ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Daemonization ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The objective of turning a process into a daemon is to detach it from its parent process&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and create a separate session for it. This is necessary, so that parent termination does not automatically cause the termination of the server as well. There is a library call that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will perform &lt;/del&gt;most of the daemonization work, called daemon, but &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it is also instructive &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;see what is necessary &lt;/del&gt;(and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;common&lt;/del&gt;) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to do &lt;/del&gt;when implementing the functionality &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;oneself&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The objective of turning a process into a daemon is to detach it from its parent process and create a separate session for it. This is necessary, so that parent termination does not automatically cause the termination of the server as well. There is a library call that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;performs &lt;/ins&gt;most of the daemonization work, called daemon, but &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;seeing what has &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;be done &lt;/ins&gt;(and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;usually is done&lt;/ins&gt;) when implementing the functionality &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can also be helpful&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Fork the process, so that the original process can be terminated and this &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will cause &lt;/del&gt;the child process to move under the system init process.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Fork the process, so that the original process can be terminated and this &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;causes &lt;/ins&gt;the child process to move under the system init process.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Create a new session for the child process with setsid.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Create a new session for the child process with setsid.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Possibly switch working directory to root (/), so that the daemon &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not keep file systems from being unmounted.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Possibly switch working directory to root (/), so that the daemon &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;does &lt;/ins&gt;not keep file systems from being unmounted.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Set up a restricted umask, so that directories and files that are created by the daemon (or its child processes) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not create publicly accessible objects in the filesystem. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;In Maemo compatible device, this &lt;/del&gt;does not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;really &lt;/del&gt;apply, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;the devices only have one user.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Set up a restricted umask, so that directories and files that are created by the daemon (or its child processes) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;do &lt;/ins&gt;not create publicly accessible objects in the filesystem. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This &lt;/ins&gt;does not &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;actually &lt;/ins&gt;apply &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;in Maemo compatible devices&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;the devices only have one user.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Close all standard I/O file descriptors (and preferably also files), so that if the terminal device closes (user logs out), it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not cause SIGPIPE signals to the daemon&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, when it &lt;/del&gt;next accesses the file descriptors (by mistake or intentionally because of g_print/printf). &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;It is also possible to reopen &lt;/del&gt;the file descriptors, so that they &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;connected to a device, which &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;just ignore all operations (like /dev/null that is used with daemon).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Close all standard I/O file descriptors (and preferably also files), so that if the terminal device closes (user logs out), it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;does &lt;/ins&gt;not cause SIGPIPE signals to the daemon &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the &lt;/ins&gt;next &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;time it &lt;/ins&gt;accesses the file descriptors (by mistake or intentionally because of g_print/printf). &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Reopening &lt;/ins&gt;the file descriptors &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is also possible&lt;/ins&gt;, so that they &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;connected to a device, which just ignore all operations (like /dev/null that is used with daemon).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The daemon function allows to select&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;whether a change of the directory is wanted&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and to close the open file descriptors. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;That will utilize &lt;/del&gt;in the servers of this example in the following way: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The daemon function allows to select whether &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;or not &lt;/ins&gt;a change of the directory is wanted and to close the open file descriptors. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This utilizes &lt;/ins&gt;in the servers of this example in the following way: glib-dbus-sync/server.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000080&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;#ifndef&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt; NO_DAEMON&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000080&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;#ifndef&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt; NO_DAEMON&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;  &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;/* This &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will attempt &lt;/del&gt;to daemonize this process. It &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will switch &lt;/del&gt;this&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;  &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;/* This &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;attempts &lt;/ins&gt;to daemonize this process. It &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;switches &lt;/ins&gt;this&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  process working directory to / (chdir) and then reopen stdin,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  process working directory to / (chdir) and then reopen stdin,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  stdout and stderr to /dev/null. Which means that all printouts&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  stdout and stderr to /dev/null. Which means that all printouts&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;would &lt;/del&gt;occur after this&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, will be &lt;/del&gt;lost. Obviously the&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  that occur after this &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;lost. Obviously the&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  daemonization &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;also &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;detach &lt;/del&gt;the process from the controlling&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  daemonization also &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;detaches &lt;/ins&gt;the process from the controlling&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  terminal as well. */&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;nbsp; &amp;nbsp;  terminal as well. */&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;  &amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#0000FF&amp;quot;&amp;gt;if&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000000&amp;quot;&amp;gt;daemon&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;)&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;!=&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;)&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#FF0000&amp;quot;&amp;gt;{&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;  &amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#0000FF&amp;quot;&amp;gt;if&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;'''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#000000&amp;quot;&amp;gt;daemon&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;'''&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;(&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;,&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;)&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;!=&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#993399&amp;quot;&amp;gt;0&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#990000&amp;quot;&amp;gt;)&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#FF0000&amp;quot;&amp;gt;{&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 40:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 40:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;/tt&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;define &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;then &lt;/del&gt;available to the user inside the Makefile: glib-dbus-sync/Makefile&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;definition &lt;/ins&gt;is available to the user inside the Makefile: glib-dbus-sync/Makefile&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;# -DNO_DAEMON : do not daemonize the server (on a separate line so can&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;lt;tt&amp;gt;&amp;lt;span&amp;gt;''&amp;lt;span&amp;gt;&amp;lt;font color=&amp;quot;#9A1900&amp;quot;&amp;gt;&amp;lt;nowiki&amp;gt;# -DNO_DAEMON : do not daemonize the server (on a separate line so can&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/span&amp;gt;''&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Since &lt;/del&gt;all -D and -U options &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;processed from left to right by gcc, this allows the -UNO_DAEMON to undefine the symbol that is preset in the Makefile. If the user does not know this technique, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it is also possible to edit &lt;/del&gt;the Makefile directly. Grouping all additional flags that the user might be interested in to the top of the Makefile &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will make &lt;/del&gt;this simpler (for the user).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Because &lt;/ins&gt;all -D and -U options &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;processed from left to right by gcc, this allows the -UNO_DAEMON to undefine the symbol that is preset in the Makefile. If the user does not know this technique, the Makefile &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;can also be edited &lt;/ins&gt;directly. Grouping all additional flags that the user might be interested in to the top of the Makefile &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;makes &lt;/ins&gt;this simpler (for the user).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Running the server with daemonization support is performed as before, but this time the &amp;amp;amp; (do not wait for child exit) token for the shell &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;left out:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Running the server with daemonization support is performed as before, but this time the &amp;amp;amp; (do not wait for child exit) token for the shell &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/ins&gt;left out:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 78:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 78:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Since &lt;/del&gt;server messages &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be &lt;/del&gt;visible any more, some other mechanism is needed to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;find out that &lt;/del&gt;the server is still running:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Because &lt;/ins&gt;server messages &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;not visible any more, some other mechanism is needed to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;determine whether or not &lt;/ins&gt;the server is still running:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;graybox&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The slightly convoluted way of using grep was necessary to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;only &lt;/del&gt;list those lines of the ps report, which have ./server in them, and to remove the lines which do not have pts in them (so that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it is possible to see &lt;/del&gt;processes which have no controlling terminals).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The slightly convoluted way of using grep was necessary to list &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;only &lt;/ins&gt;those lines of the ps report, which have ./server in them, and to remove the lines which do not have pts in them (so that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;seeing the &lt;/ins&gt;processes which have no controlling terminals &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is possible&lt;/ins&gt;).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The client could have been used to test&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;whether the server responds, but the above technique is slightly more general. If the pstree tool is available, it could be run it with -pu options to see how the processes relate to each other&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/del&gt;and that the daemonized server is running directly as a child of init (which was the objective of the fork).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The client could have been used to test whether the server responds, but the above technique is slightly more general. If the pstree tool is available, it could be run it with -pu options to see how the processes relate to each other and that the daemonized server is running directly as a child of init (which was the objective of the fork).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Event Loops and Power Consumption ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Event Loops and Power Consumption ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:28 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 16 Sep 2009 10:43:23 GMT</pubDate>			<dc:creator>liox_lang_valid</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>liox_lang_valid:&amp;#32;/* Definition of Server */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18208&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=18208&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Definition of Server&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 09:12, 16 September 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Definition of Server ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Definition of Server ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When talking about software, a server is commonly understood to mean some kind of software component that provides a service to its clients. In Linux, servers are usually implemented as daemons, which is a technical term for a process that has detached from the terminal session, and performed other preparatory actions, so that it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will stay &lt;/del&gt;running on the background until it terminates (or is terminated).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When talking about software, a server is commonly understood to mean some kind of software component that provides a service to its clients. In Linux, servers are usually implemented as daemons, which is a technical term for a process that has detached from the terminal session, and performed other preparatory actions, so that it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;stays &lt;/ins&gt;running on the background until it terminates (or is terminated).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Sometimes people might refer to servers as engines, but it is a more generic term, and normally is not related directly to the way a service is implemented (as a separate process, or as part of some library, directly used from within a client process). Broadly defined, an engine is the part of application that implements the functionality, but not the interface, of an application. In Model-View-Controller, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it would be &lt;/del&gt;the Model.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Sometimes people might refer to servers as engines, but it is a more generic term, and normally is not related directly to the way a service is implemented (as a separate process, or as part of some library, directly used from within a client process). Broadly defined, an engine is the part of application that implements the functionality, but not the interface, of an application. In Model-View-Controller, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the engine is &lt;/ins&gt;the Model.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The servers in these examples have so far been running without daemonization, in order to display debugging messages on the terminal/screen more easily. Often a server can be started with a &amp;quot;&amp;lt;code&amp;gt;--stay-on-foreground&amp;lt;/code&amp;gt;&amp;quot; option (or -f or something similar), which means that they &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;not daemonize. This is a useful feature to have, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;since &lt;/del&gt;it &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will allow &lt;/del&gt;the use of simpler outputting primitives, when testing the software.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The servers in these examples have so far been running without daemonization, in order to display debugging messages on the terminal/screen more easily. Often a server can be started with a &amp;quot;&amp;lt;code&amp;gt;--stay-on-foreground&amp;lt;/code&amp;gt;&amp;quot; option (or -f or something similar), which means that they &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;do &lt;/ins&gt;not daemonize. This is a useful feature to have, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;it &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;allows &lt;/ins&gt;the use of simpler outputting primitives, when testing the software.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;By default, when a server daemonizes, its output and input files &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/del&gt;closed, so reading user input (from the terminal session, not GUI) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will fail&lt;/del&gt;, as &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;will &lt;/del&gt;each output write (including printf and g_print).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;By default, when a server daemonizes, its output and input files &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are &lt;/ins&gt;closed, so reading user input (from the terminal session, not GUI) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;fails&lt;/ins&gt;, as &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;does &lt;/ins&gt;each output write (including printf and g_print).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Daemonization ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Daemonization ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:28 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 16 Sep 2009 09:12:48 GMT</pubDate>			<dc:creator>liox_lang_valid</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
		<item>
			<title>bijjal:&amp;#32;/* Debugging */</title>
			<link>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=16950&amp;oldid=prev</link>
			<guid>http://bugs.maemo.com/index.php?title=Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues&amp;diff=16950&amp;oldid=prev</guid>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Debugging&lt;/span&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:14, 26 August 2009&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For larger projects, it is advisable to combine __file__, so that tracing multifile programs will become easier.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;For larger projects, it is advisable to combine __file__, so that tracing multifile programs will become easier.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which would be using the client code, and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. It can also be of interest to use Valgrind to help detecting memory leaks (and some other errors). More information on these topics and examples &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;is &lt;/del&gt;available in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;section ''&lt;/del&gt;Maemo Debugging Guide&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'' [&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;node16.html#sec:maemo_debugging_guide 15.2] of chapter ''&lt;/del&gt;Debugging&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'' on &lt;/del&gt;Maemo &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Reference Manual.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Coupled with proper test cases (which would be using the client code, and possibly also dbus-send in D-Bus related programs), this is a very powerful technique, and often much easier than single stepping through the code with a debugger (gdb), or setting evaluation breakpoints. It can also be of interest to use Valgrind to help detecting memory leaks (and some other errors). More information on these topics and examples &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;will be &lt;/ins&gt;available in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the [[Documentation/&lt;/ins&gt;Maemo &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;5 Developer Guide/Kernel and &lt;/ins&gt;Debugging Guide/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Maemo &lt;/ins&gt;Debugging &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Guide|&lt;/ins&gt;Maemo &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Debugging Guide]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2026-04-04 10:13:28 --&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 26 Aug 2009 12:14:50 GMT</pubDate>			<dc:creator>bijjal</dc:creator>			<comments>http://bugs.maemo.com/Talk:Documentation/Maemo_5_Developer_Guide/DBus/D-Bus_Server_Design_Issues</comments>		</item>
	</channel>
</rss>