From 577427e68ef10a4d2b75d28e42b22952ae3bcf23 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 02 Jul 2006 22:16:25 +0000 Subject: Do not close RRQ socket until the last ACK is received. git-svn-id: http://svn.klever.net/kin/pumpkin/trunk@152 fe716a7a-6dde-0310-88d9-d003556173a8 --- diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp index 070f3e8..2a01918 100644 --- a/PumpKINDlg.cpp +++ b/PumpKINDlg.cpp @@ -579,10 +579,10 @@ int rv = socket->SendTo(udpBase(),length,(SOCKADDR*)saddr,sizeof(SOCKADDR_IN)); return TRUE; } -void CXferSocket::DoSelect() +void CXferSocket::DoSelect(BOOL do_select) { if(m_Peer.sin_addr.s_addr!=INADDR_NONE) - AsyncSelect(FD_CLOSE|FD_READ|(m_Queue.IsEmpty()?0:FD_WRITE)); + AsyncSelect(FD_CLOSE|FD_READ|((m_Queue.IsEmpty()&&!do_select)?0:FD_WRITE)); } void CXferSocket::OnReceive(int nErrorCode) @@ -854,11 +854,7 @@ tftp *p = tftp::Allocate(tftp::tftpDATA::tftpSize(m_blkSize)); m_LastSlack = m_blkSize-bytes; PostTFTP(p); if(bytesLogLine(tmp); + state=stateClosing; m_ACKtoClose = m_ACK+1; } }CATCH(CFileException,e){ Deny(e); @@ -936,39 +932,47 @@ BOOL CRRQSocket::OnTFTP(tftp* p) BOOL rv = TRUE; switch(p->Opcode()){ case tftp::opOACK: - m_ACK=0; - ASSERT(state!=stateFinish); - { - tftp::tftpOptions o; - if(p->GetOptions(&o)){ - CString v; - if(o.Lookup(tftpoBSize,v)){ - m_blkSize=atoi(v); - if(!m_blkSize){ // *** More sanity checks - Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE); - rv = TRUE; - break; + { + m_ACK=0; + ASSERT(state!=stateFinish); + tftp::tftpOptions o; + if(p->GetOptions(&o)){ + CString v; + if(o.Lookup(tftpoBSize,v)){ + m_blkSize=atoi(v); + if(!m_blkSize){ // *** More sanity checks + Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE); + rv = TRUE; + break; + } } - } - if(o.Lookup(tftpoTOut,v)){ - m_timeOut=atoi(v); - if(!m_timeOut){ // *** More sanity checks - Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); - rv = TRUE; - break; + if(o.Lookup(tftpoTOut,v)){ + m_timeOut=atoi(v); + if(!m_timeOut){ // *** More sanity checks + Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT); + rv = TRUE; + break; + } + } + if(o.Lookup(tftpoXResume,v)){ + m_ACK=atoi(v); } } - if(o.Lookup(tftpoXResume,v)){ - m_ACK=atoi(v); - } + UpdateList(); + DoXfer(); } - UpdateList(); - DoXfer(); - } break; case tftp::opACK: m_ACK=p->data.m_ACK.Block(); - if(state!=stateFinish){ + if(state==stateClosing && m_ACK==m_ACKtoClose) { + state = stateFinish; + ASSERT(m_Daddy); + CString tmp; + tmp.Format(IDS_LOG_XFERRRQFINISHED,(LPCTSTR)m_FileName); + m_Daddy->LogLine(tmp); + rv = FALSE; + DoSelect(TRUE); + }else if(state!=stateFinish){ UpdateList(); DoXfer(); } diff --git a/PumpKINDlg.h b/PumpKINDlg.h index c5469f1..23c2657 100644 --- a/PumpKINDlg.h +++ b/PumpKINDlg.h @@ -312,7 +312,7 @@ public: void SetPeer(SOCKADDR_IN *sin); virtual BOOL OnTFTP(tftp* p) = 0; virtual void OnReceive(int nErrorCode); - void DoSelect(); + void DoSelect(BOOL do_select=FALSE); SOCKADDR_IN m_Peer; virtual void OnSend(int nErrorCode); CPumpKINDlg* m_Daddy; @@ -341,6 +341,7 @@ public: }; class CRRQSocket : public CXferSocket { public: + UINT m_ACKtoClose; void OnHostKnown(); virtual void OnResolved(); BOOL ConfirmRequest(); diff --git a/pumpkin.mak b/pumpkin.mak index a22a6fa..bf9e895 100644 --- a/pumpkin.mak +++ b/pumpkin.mak @@ -686,9 +686,6 @@ LINK32_OBJS= \ # Begin Source File SOURCE=.\PumpKIN.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_PUMPK=\ ".\pumpkin.h"\ ".\PumpKINDlg.h"\ @@ -697,19 +694,15 @@ DEP_CPP_PUMPK=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_PUMPK=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -720,13 +713,6 @@ DEP_CPP_PUMPK=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_PUMPK=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -739,6 +725,9 @@ DEP_CPP_PUMPK=\ # Begin Source File SOURCE=.\PumpKINDlg.cpp + +!IF "$(CFG)" == "PumpKIN - Win32 Release" + DEP_CPP_PUMPKI=\ ".\ACLTargetCombo.h"\ ".\ConfirmRRQDlg.h"\ @@ -758,15 +747,32 @@ DEP_CPP_PUMPKI=\ ".\Trayer.h"\ -!IF "$(CFG)" == "PumpKIN - Win32 Release" - - "$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" +DEP_CPP_PUMPKI=\ + ".\ACLTargetCombo.h"\ + ".\ConfirmRRQDlg.h"\ + ".\ConfirmWRQDlg.h"\ + ".\PropsACL.h"\ + ".\PropsNetwork.h"\ + ".\PropsServer.h"\ + ".\PropsSounds.h"\ + ".\pumpkin.h"\ + ".\PumpKINDlg.h"\ + ".\RequestDlg.h"\ + ".\Resolver.h"\ + ".\Retrier.h"\ + ".\shared-code\kHelpers.h"\ + ".\stdafx.h"\ + ".\Trayer.h"\ + +NODEP_CPP_PUMPKI=\ + ".\DoSelect"\ + "$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -777,6 +783,24 @@ DEP_CPP_PUMPKI=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" +DEP_CPP_PUMPKI=\ + ".\ACLTargetCombo.h"\ + ".\ConfirmRRQDlg.h"\ + ".\ConfirmWRQDlg.h"\ + ".\PropsACL.h"\ + ".\PropsNetwork.h"\ + ".\PropsServer.h"\ + ".\PropsSounds.h"\ + ".\pumpkin.h"\ + ".\PumpKINDlg.h"\ + ".\RequestDlg.h"\ + ".\Resolver.h"\ + ".\Retrier.h"\ + ".\shared-code\BellsNWhistles.h"\ + ".\shared-code\kHelpers.h"\ + ".\stdafx.h"\ + ".\Trayer.h"\ + "$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -986,9 +1010,6 @@ BuildCmds= \ # Begin Source File SOURCE=.\PropsServer.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_PROPS=\ ".\PropsServer.h"\ ".\pumpkin.h"\ @@ -997,19 +1018,15 @@ DEP_CPP_PROPS=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_PROPS=\ - ".\PropsServer.h"\ - ".\pumpkin.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1020,13 +1037,6 @@ DEP_CPP_PROPS=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_PROPS=\ - ".\PropsServer.h"\ - ".\pumpkin.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1078,9 +1088,6 @@ DEP_CPP_PROPSN=\ # Begin Source File SOURCE=.\ConfirmRRQDlg.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_CONFI=\ ".\ConfirmRRQDlg.h"\ ".\pumpkin.h"\ @@ -1090,20 +1097,15 @@ DEP_CPP_CONFI=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_CONFI=\ - ".\ConfirmRRQDlg.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1114,14 +1116,6 @@ DEP_CPP_CONFI=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_CONFI=\ - ".\ConfirmRRQDlg.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1134,9 +1128,6 @@ DEP_CPP_CONFI=\ # Begin Source File SOURCE=.\ConfirmWRQDlg.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_CONFIR=\ ".\ConfirmWRQDlg.h"\ ".\pumpkin.h"\ @@ -1146,20 +1137,15 @@ DEP_CPP_CONFIR=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_CONFIR=\ - ".\ConfirmWRQDlg.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1170,14 +1156,6 @@ DEP_CPP_CONFIR=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_CONFIR=\ - ".\ConfirmWRQDlg.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1229,9 +1207,6 @@ DEP_CPP_REQUE=\ # Begin Source File SOURCE=.\Resolver.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_RESOL=\ ".\pumpkin.h"\ ".\PumpKINDlg.h"\ @@ -1241,20 +1216,15 @@ DEP_CPP_RESOL=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_RESOL=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\Resolver.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1265,14 +1235,6 @@ DEP_CPP_RESOL=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_RESOL=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\Resolver.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1285,9 +1247,6 @@ DEP_CPP_RESOL=\ # Begin Source File SOURCE=.\Retrier.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_RETRI=\ ".\pumpkin.h"\ ".\PumpKINDlg.h"\ @@ -1297,20 +1256,15 @@ DEP_CPP_RETRI=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_RETRI=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\Retrier.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1321,14 +1275,6 @@ DEP_CPP_RETRI=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_RETRI=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\Retrier.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1341,9 +1287,6 @@ DEP_CPP_RETRI=\ # Begin Source File SOURCE=.\Trayer.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_TRAYE=\ ".\pumpkin.h"\ ".\PumpKINDlg.h"\ @@ -1353,20 +1296,15 @@ DEP_CPP_TRAYE=\ ".\Trayer.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_TRAYE=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - ".\Trayer.h"\ - "$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1377,14 +1315,6 @@ DEP_CPP_TRAYE=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_TRAYE=\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - ".\Trayer.h"\ - "$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1417,9 +1347,6 @@ SOURCE=.\help\pumpkin.cnt # Begin Source File SOURCE=.\PropsSounds.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_PROPSS=\ ".\PropsSounds.h"\ ".\pumpkin.h"\ @@ -1429,20 +1356,15 @@ DEP_CPP_PROPSS=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_PROPSS=\ - ".\PropsSounds.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1453,14 +1375,6 @@ DEP_CPP_PROPSS=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_PROPSS=\ - ".\PropsSounds.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1514,9 +1428,6 @@ DEP_CPP_PROPSA=\ # Begin Source File SOURCE=.\ACLTargetCombo.cpp - -!IF "$(CFG)" == "PumpKIN - Win32 Release" - DEP_CPP_ACLTA=\ ".\ACLTargetCombo.h"\ ".\pumpkin.h"\ @@ -1526,20 +1437,15 @@ DEP_CPP_ACLTA=\ ".\stdafx.h"\ +!IF "$(CFG)" == "PumpKIN - Win32 Release" + + "$(INTDIR)\ACLTargetCombo.obj" : $(SOURCE) $(DEP_CPP_ACLTA) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" !ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug" -DEP_CPP_ACLTA=\ - ".\ACLTargetCombo.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ACLTargetCombo.obj" : $(SOURCE) $(DEP_CPP_ACLTA) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" @@ -1550,14 +1456,6 @@ DEP_CPP_ACLTA=\ !ELSEIF "$(CFG)" == "PumpKIN - Win32 Static" -DEP_CPP_ACLTA=\ - ".\ACLTargetCombo.h"\ - ".\pumpkin.h"\ - ".\PumpKINDlg.h"\ - ".\shared-code\BellsNWhistles.h"\ - ".\shared-code\kHelpers.h"\ - ".\stdafx.h"\ - "$(INTDIR)\ACLTargetCombo.obj" : $(SOURCE) $(DEP_CPP_ACLTA) "$(INTDIR)"\ "$(INTDIR)\pumpkin.pch" -- cgit v0.9.0.2