Hey ya!

Sometimes I had this kind of warning in my network log:

20:54:52: [WRN] Socket 21 does not exist (#4294967295).

After that some direct connections did not work.
The cause for the bug was that INetSocket::m_szOwnerId and
INetSocket::m_nOwnerPPID were both 0 and when closing the
socket it remained in the user's object.

Maybe this case is under development because I found from file
include/licq_socket.h method INetSocket::SetOwner(const char *s,
unsigned long n) which was not implemented anywhere. In
CICQDaemon::Handshake_Recv() socket's method SetOwner() is called
but it doesn't set these m_szOwnerId and m_nOwnerPPID values.

So in the attached patch I implemented this missing function
and it's called in Handshake_Recv() function. It will set
those m_szOwnerId and m_nOwnerPPID values. When time to close the
socket and destroy all references to it comes, it will happen
properly and we are not going to try to use it anymore.

The code in the patch file may not be what it should be (I'm not
sure how Jon or Thomas designed this), so it's just a reference
how to fix this problem. If the problem was known and just under
development, sorry about the rushing. :)

The patch file is against the current cvs and it can be downloaded
from here:
http://tumppi.net/licq/licq-socket-fix2.diff

Regards,
--
# Tuomas Jaakola
Index: src/icqd-tcp.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-tcp.cpp,v
retrieving revision 1.58
diff -u -1 -b -p -u -r1.58 icqd-tcp.cpp
--- src/icqd-tcp.cpp    2 Jul 2003 04:41:01 -0000       1.58
+++ src/icqd-tcp.cpp    18 Jan 2004 22:02:13 -0000
@@ -2803,3 +2803,5 @@ bool CICQDaemon::Handshake_Recv(TCPSocke
 
-  s->SetOwner(nUin);
+  char szUin[24];
+  sprintf(szUin, "%lu", nUin);
+  s->SetOwner(szUin, LICQ_PPID);
   s->SetVersion(nVersion);
Index: src/socket.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/socket.cpp,v
retrieving revision 1.36
diff -u -1 -b -p -u -r1.36 socket.cpp
--- src/socket.cpp      12 Jan 2004 15:26:19 -0000      1.36
+++ src/socket.cpp      18 Jan 2004 22:02:13 -0000
@@ -170,2 +170,13 @@ char *INetSocket::RemoteIpStr(char *buf)
 
+//-----INetSocket::SetOwner---------------------------------------------------
+void INetSocket::SetOwner(const char *_szOwnerId, unsigned long _nOwnerPPID)
+{
+  m_szOwnerId = strdup(_szOwnerId);
+  m_nOwnerPPID = _nOwnerPPID;
+  if (m_nOwnerPPID == LICQ_PPID)
+    m_nOwner = strtoul(_szOwnerId, (char **)NULL, 10);
+  else
+    m_nOwner = 0;
+}
+
 

Reply via email to