From: Matze B. <mat...@us...> - 2002-04-28 19:44:45
|
Update of /cvsroot/planeshift/planeshift/src/common/net In directory usw-pr-cvs1:/tmp/cvs-serv30565 Modified Files: netbase.cpp netbase.h netpacket.h Log Message: fixed another leak - the incoming packets haven't always been deleted Index: netbase.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/net/netbase.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** netbase.cpp 27 Apr 2002 17:27:57 -0000 1.68 --- netbase.cpp 27 Apr 2002 17:55:30 -0000 1.69 *************** *** 192,205 **** splitpacket = pkt->GetNextPacket(packetdata); if (splitpacket) ! BuildMessage(splitpacket,connection,&addr); ! } while (packetdata); /** ! * If we split apart a multipacket packet above, we are done ! * with the merged one now. */ if (splitpacket != pkt) ! delete pkt; return true; --- 192,210 ---- splitpacket = pkt->GetNextPacket(packetdata); if (splitpacket) ! { ! if (!BuildMessage(splitpacket, connection, &addr)) ! { ! // if BuildMessage didn't store it we should delete it now ! delete splitpacket; ! } ! } } while (packetdata); /** ! * If we split apart a multipacket packet above, remove the merged one ! * now, because the loop above doesn't do it in this case */ if (splitpacket != pkt) ! delete pkt; return true; *************** *** 558,562 **** } ! void NetBase::BuildMessage(psNetPacketEntry* pkt, Connection* connection, LPSOCKADDR_IN addr) { --- 563,567 ---- } ! bool NetBase::BuildMessage(psNetPacketEntry* pkt, Connection* connection, LPSOCKADDR_IN addr) { *************** *** 577,581 **** MsgEntry* me = new MsgEntry(msg); HandleCompletedMessage(me, connection, addr); ! return; } --- 582,586 ---- MsgEntry* me = new MsgEntry(msg); HandleCompletedMessage(me, connection, addr); ! return false; } *************** *** 587,590 **** --- 592,597 ---- if (me) HandleCompletedMessage(me, connection, addr); + + return true; } *************** *** 638,641 **** --- 645,649 ---- pkt->p->pktsize); packets.Delete(pkt); + delete pkt; deleted = false; break; Index: netbase.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/net/netbase.h,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** netbase.h 24 Apr 2002 19:27:47 -0000 1.44 --- netbase.h 27 Apr 2002 17:55:30 -0000 1.45 *************** *** 179,183 **** * complete message is reassembled, it calls HandleCompletedMessage(). */ ! void BuildMessage(psNetPacketEntry* pkt,Connection *connection,LPSOCKADDR_IN addr); /** --- 179,183 ---- * complete message is reassembled, it calls HandleCompletedMessage(). */ ! bool BuildMessage(psNetPacketEntry* pkt,Connection *connection,LPSOCKADDR_IN addr); /** Index: netpacket.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/net/netpacket.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** netpacket.h 27 Apr 2002 16:10:00 -0000 1.14 --- netpacket.h 27 Apr 2002 17:55:30 -0000 1.15 *************** *** 56,60 **** /** this can be used as a pointer to the data */ ! char data[0]; //------------------------------------------------------------------------ --- 56,60 ---- /** this can be used as a pointer to the data */ ! char data[0] PS_PACKED; //------------------------------------------------------------------------ |