--- daemon.h	Tue May 14 21:47:15 2002
+++ daemon.h	Thu Mar 11 21:51:21 2004
@@ -45,21 +45,6 @@
 #endif
 };
 
-/// This class is obsolete
-/* So get rid of it ;)
-class CMyDataSource : public CDataSource
-{
-public:
-	CSQLDatabase* m_database;
-
-public:
-	CMyDataSource(CSQLDatabase* db)
-	{
-		m_database = db;
-	}
-	virtual void GetCloneList(const char *crc, CUrlW* origin, CSrcDocVector &docs);
-};
-*/
 
 class CWorkerThreadList;
 
@@ -70,9 +55,10 @@
 	CEvent m_req;			///< CEvent object, posted on request
 	pthread_t m_thread;		///< Thread ID
 	int m_socket;			///< Socket returned by accept
+	int m_removed;			///< object has been removed from the linked list
 	CSQLDatabase* m_database;	///< Database associated with thread
 	CWorkerThread* m_next;		///< Next CWorkerThread in the linked list of threads
-	CWorkerThread** m_prev;		///< Pointer to the location of pointer to this CWorkerThread in the preivious object linked list of threads
+	CWorkerThread* m_prev;		///< Previous CWorkerThread in the linked list of threads
 	CWorkerThreadList* m_parent;	///< Pointer to the linked list object holding worker threads
 
 public:
@@ -81,25 +67,23 @@
 		m_next = NULL;
 		m_prev = NULL;
 		m_parent = NULL;
+		m_database = NULL;
 		m_thread = 0;
 		m_socket = 0;
+		m_removed = 0;
 	}
-	/// This method removes current object from linked list
-	CWorkerThread* Remove()
-	{
-		if (m_prev)
-		{
-			*m_prev = m_next;
-		}
-		return this;
-	}
-	/// This method inserts current object after specified in the linked list
-	void Insert(CWorkerThread** prev)
+	~CWorkerThread()
 	{
-		m_next = *prev;
-		m_prev = prev;
-		*m_prev = this;
+		m_prev = NULL;
+		m_next = NULL;
+		m_parent = NULL;
+		m_database = NULL;
+		m_thread = 0;
+		m_socket = 0;
+		m_removed = 1;
 	}
+	CWorkerThread* Remove();
+	void Insert(CWorkerThread* prev);
 };
 
 #define MAX_WAITING_SOCKETS 1024
@@ -153,6 +137,40 @@
 	/// Process incoming request, source of request is socket "csock"
 	void processReq(CSQLDatabase* database, int csock);
 };
+
+	/// This method inserts current object after specified in the linked list
+	inline void CWorkerThread::Insert(CWorkerThread* prev)
+	{
+		m_next = prev->m_next;
+		if(prev->m_next)
+			prev->m_next->m_prev = this;
+		prev->m_next = this;
+		m_prev = prev;
+		m_removed = 0;
+	}
+	/// This method removes current object from linked list
+	inline CWorkerThread* CWorkerThread::Remove()
+	{
+		
+		if(m_next)
+		{
+			if(m_parent->m_first == this)
+				m_parent->m_first = m_next;
+			m_next->m_prev = m_prev;
+		}
+		if(m_prev)
+		{
+			if(m_parent->m_first == this)
+				m_parent->m_first = m_prev;
+			m_prev->m_next = m_next;
+		}
+		else if(!m_next)
+			m_parent->m_first = NULL;
+		m_prev = NULL;
+		m_next = NULL;
+		m_removed = 1;
+		return this;
+	}
 
 /** Auxiliary class for simple mutex locking.
  * Locks mutex, specified by parameter of constructor, and unlocks it

