[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in SocketService
From: |
Byrial Jensen |
Subject: |
Bug in SocketService |
Date: |
Wed, 10 Mar 2004 16:21:46 +0100 |
Hi,
I had some trouble using SocketService which I think could be caused
by SocketService::count and SocketService::first not being declared
volatile.
These 2 variables are read several times inside a loop in
SocketService::run(), and an optimizing compiler may reduce the
number of actual read accesses or even move the reading out of
the main loop. That would give bad results as the variables may
be changed by other threads calling SocketService::attach() and
SocketService::detach().
I suggest the following patch to fix the problem:
--- include/cc++/socket.h~ Wed Dec 10 10:41:07 2003
+++ include/cc++/socket.h Wed Mar 10 16:19:47 2004
@@ -2077,8 +2077,8 @@
class Sync;
Sync* sync;
#endif
- int count;
- SocketPort *first, *last;
+ int volatile count;
+ SocketPort * volatile first, *last;
/**
* Attach a new socket port to this service thread.
Best regards,
Byrial Jensen
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug in SocketService,
Byrial Jensen <=