diff --git a/Makefile b/Makefile index 692a9a5..b884108 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.9.5.2 +VERSION := 0.9.5.3 .PHONY: lint vis clean common client server passwd subpkgs install uninstall reinstall ## Tag version of binaries with build info wrt. diff --git a/xsd/xsd.go b/xsd/xsd.go index 44762a8..1fcef4f 100755 --- a/xsd/xsd.go +++ b/xsd/xsd.go @@ -327,16 +327,6 @@ func runShellAs(who, hname, ttype, cmd string, interactive bool, //nolint:funlen // #gv:s/label=\"runShellAs\$1\"/label=\"deferPtmxClose\"/ defer func() { //logger.LogDebug(fmt.Sprintf("[Exited process was %d]", c.Process.Pid)) - - //Ensure socket has sent all data to client prior to closing - //NOTE: This is not ideal, as it would be better to somehow - //determine if there is any pending outgoing (write) data to the - //underlying socket (TCP/KCP) prior to closing; however Go's net pkg - //completely hides lower-level stuff. net.Conn.Close() according to - //docs sends written data in the background, so how best to determine - //all data has been sent? -rlm 2022-10-04 - - time.Sleep(100 * time.Millisecond) //Empirically determined :^/ _ = ptmx.Close() }() @@ -869,9 +859,6 @@ func main() { //nolint:funlen,gocyclo // Returned hopefully via an EOF or exit/logout; logger.LogNotice(fmt.Sprintf("[s->c copy completed for %s@%s, status %d]\n", rec.Who(), hname, cmdStatus)) //nolint:errcheck } - // HACK: Bug #22: (xc) Need to wait for rcvr to get final data - // TODO: Await specific msg from client to inform they have gotten all data from the tarpipe - time.Sleep(900 * time.Millisecond) //nolint:gomnd // Let rcvr set this on setup? // Clear current op so user can enter next, or EOF rec.SetOp([]byte{0}) diff --git a/xsnet/net.go b/xsnet/net.go index 131c1cf..9ba7cd8 100644 --- a/xsnet/net.go +++ b/xsnet/net.go @@ -267,8 +267,6 @@ func _new(kexAlg KEXAlg, conn *net.Conn) (hc *Conn, e error) { tempMap := make(map[uint16]*TunEndpoint) hc.tuns = &tempMap - *hc.closeStat = CSEStillOpen // open or prematurely-closed status - // Set up KEx/KEM-specifics switch kexAlg { case KEX_HERRADURA256: @@ -979,6 +977,19 @@ func (hc *Conn) Close() (err error) { log.Printf("** Writing closeStat %d at Close()\n", *hc.closeStat) //(*hc.c).SetWriteDeadline(time.Now().Add(500 * time.Millisecond)) hc.WritePacket(s, CSOExitStatus) + + // HACK: Bug #22,#33: Need to wait for rcvr to get final data + // TODO: Find a way to explicitly check if any outgoing data is pending + + //Ensure socket has sent all data to client prior to closing + //NOTE: This is not ideal, as it would be better to somehow + //determine if there is any pending outgoing (write) data to the + //underlying socket (TCP/KCP) prior to closing; however Go's net pkg + //completely hides lower-level stuff. net.Conn.Close() according to + //docs sends written data in the background, so how best to determine + //all data has been sent? -rlm 2022-10-04 + time.Sleep(10 * time.Millisecond) //nolint:gomnd + err = (*hc.c).Close() logger.LogDebug(fmt.Sprintln("[Conn Closing]")) return