[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error in SocketService::run()
From: |
klaus triendl \(daten unlimited\) |
Subject: |
error in SocketService::run() |
Date: |
Mon, 4 Nov 2002 15:41:07 +0100 |
hi,
i tested the SampleSocketPort example with WinXP. i changed the example a
little - the server disconnects in the SampleSocketPort::expired() method
with disconnect(). This means that CloseSocket() is called with
m_bDoDisconnect=true and the SocketPort is deleted.
SampleSocketPort::expired() is called in SocketService::run(); after it
returns the whole starts from the beginning referring to the already deleted
object causing a segfault:
SocketService::run():
retry:
expires = port->getTimer(); // still returns 0 if port
object has been
deleted
if(expires > 0)
if(expires < timer)
timer = expires;
// if we expire, get new scheduling now
if(!expires)
{
port->endTimer(); // sets active=false
port->expired(); // segfault when it comes here
the 2nd time
// ^^^^^^^^^^^^^^^^ port object is deleted the 1st
time
goto retry;
}
port = port->next; // points to some address after the
port object is
deleted
the funny thing is that port->getTimer() (baseclass-method of
SampleSocketPort) doesn't cause a segfault after SampleSocketPort is
deleted, but i guess this is due to how objects are stored in memory. but
this doesn't help us because after the SampleSocketPort object is deleted
port->getTimer() still returns 0 and active has probably some value
(something other than 0 or 1 - i tested it), therefore we cannot rely on
active=false. we also cannot be sure that port->next=NULL or
port->next="address of next open port".
a possibility to handle this problem would be to let expired() return false
or true according to whether the object was deleted and to have a second
port pointer pointing to port->prev which comes into play if expired()
returns false (while deleting the port it detaches itself from the service,
thus 2ndportpointer->next would point to port->next).
any comments or suggestions?
--
klaus triendl
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- error in SocketService::run(),
klaus triendl \(daten unlimited\) <=