mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
Cleaner fix for issues #22,#33
This commit is contained in:
parent
9ca5ccae32
commit
5ee09de99a
3 changed files with 14 additions and 16 deletions
15
xsnet/net.go
15
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue