1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
|
<!-- $Id: ACE-FMM.html 80826 2008-03-04 14:51:23Z wotte $ -->
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>ACE FMM</title>
</head>
<body bgcolor=#ffffff>
<center>
<font face=helvetica size=5>ACE Frequently Made Mistakes</font>
<br>
<br>
<table border=0 cellpadding=3 cellspacing=1 width=550>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
ACE_Task::getq() returns the error
<b>resource temporarily unavailable</b>
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
Your Task is a subclass of ACE_Task<ACE_NULL_SYNCH> and
you are using it in a multithreaded program.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Try using ACE_Task<ACE_MT_SYNCH>
instead so that the associated Message_Queue
is configured for access by multiple threads.
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
ACE_Task::wait() throws an assert violation
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
When you activate()d your Task, you specified
THR_DETACHED, which causes wait() to be unable to perform what you
want it to.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Make sure you specify the flag THR_JOINABLE when activating
your ACE_Task object.
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
Apparent race conditions when spawning threads (or activating Tasks)
from within a constructor.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
You are not guaranteed to have a valid <b>this</b> pointer
until the constructor has exited. Threads spawned from
a constructor are free to run
immediately, and may attempt to use an invalid <b>this</b> pointer.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Move your Task activations and other thread-spawning activites
<b>out</b> of the constructor.
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
Compiler issues warnings/erros regarding using too few template
arguments, such as "'ACE_Svc_Handler' : too few template arguments".
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
Instead of using the appropriate macro, you supplied an actual class
name as a parameter. This will fail depending upon platform and compiler,
due to the way templates are handled.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Instead of instantiating a template class like <b>ACE_Svc_Handler<<u>ACE_SOCK_Stream</u>, ACE_NULL_SYNCH></b>, use the form of <b>ACE_Svc_Handler<<u>ACE_SOCK_STREAM</u>, ACE_NULL_SYNCH></b> which circumvents the platform peculiarities by using the macro. This also applies to some other template classes.
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
Unable to compare ACE_thread_t variables (such as ACE_Thread::self())
using operator== ().
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
On some platforms, thread ids are numeric, and on some, they aren't. On some
implementations, simple a == b comparisons
are legal and sane. Some are not.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Use the <b>ACE_OS::thr_equal()</b> function to reliably compare thread
ids, regardless of platform.
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
ACE_Reactor::run_event_loop() does not seem to function correctly
for a Reactor created in your application.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
You have not set the ACE_Reactor::instance() to refer to your new reactor.
run_event_loop only functions on the reactor currently installed as the
global Singleton.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Use the <b>ACE_Reactor::instance(ACE_Reactor *,
int delete_reactor = 0)</b> static method to install your reactor as the global
Singleton before calling run_event_loop().
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
Infinite recursion when you invoke ACE_Reactor::remove_handler()
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
You are invoking remove_handler() from within handle_close() (or a
method invoked by handle_close()) but you have not specified the
DONT_CALL flag.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
Be sure to <b>OR</b> in the DONT_CALL flag in this situation.<br>
e.g. --<br>
<ul><pre>
int MyHandler::handle_close (ACE_HANDLE handle,
ACE_Reactor_Mask close_mask)
{
...
my_reactor_->remove_handler( this,
ACE_Event_Handler::READ_MASK |
ACE_Event_Handler::DONT_CALL );
...
return 0;
}
</pre></ul>
</td>
<tr><td colspan=2><hr noshade></td></tr>
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
Application crashes after deleting Event_Handler.
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
You left a dangling pointer to the Event_Handler in the Reactor.
It is the application's responsibility to remove all pending notifications,
timer events and completely remove the event handler I/O registrations
before removing the event handler.
Also, the application should remove the event handler from the reactor
<b>before</b> closing the underlying file descriptor / handle.
Otherwise:
<ul>
<li>The reactor does not know how to remove the event handler, because the
handle is used as the identifier for the event handlers</li>
<li>The file descriptor / handle may be reused by another thread, leading to
nasty race conditions.</li>
</ul>
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
<ul>
<li>Use reference counted event handlers. The reactor and the application
cooperate to remove the event handler when the last reference goes away.
</li>
<li>Remember to call <tt>purge_pending_notifications()</tt>,
<tt>remove_handler()</tt> and <tt>cancel_timer()</tt> before deleting the
event handler.
</li>
</ul>
</td>
<td align=left valign=top>
</td>
<tr><td colspan=2><hr noshade></td></tr>
<!--
<tr>
<td align=right valign=top>
<b>symptom</b>
</td>
<td align=left valign=top>
</td>
</tr>
<tr>
<td align=right valign=top>
<b>probable cause</b>
</td>
<td align=left valign=top>
</td>
</tr>
<tr>
<td align=right valign=top>
<b>solution</b>
</td>
<td align=left valign=top>
</td>
<tr><td colspan=2><hr noshade></td></tr>
-->
<tr>
<td align=center colspan=2>
<font size=2>maintained by <a href="mailto:bob@werken.com">bob@werken.com</a></font>
</td>
</tr>
</table>
</center>
Back to <A HREF="index.html">ACE Documentation Home</A>.
</body>
</html>
|