Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu is greater than 100% when close() is called #39

Open
yellzhi opened this issue Sep 26, 2024 · 0 comments
Open

cpu is greater than 100% when close() is called #39

yellzhi opened this issue Sep 26, 2024 · 0 comments

Comments

@yellzhi
Copy link

yellzhi commented Sep 26, 2024

  1. When the resident process called close(), cpu utilization exceeds 100%

2.we found a possible code:

` ledger_hid.go

func (ledger *LedgerDeviceHID) readThread() {
defer close(ledger.readChannel)
for {
	buffer := make([]byte, PacketSize)
	readBytes, err := ledger.device.Read(buffer)

	// Check for HID Read Error (May occur even during normal runtime)
	if err != nil {
		continue
	}

	// Discard all zero packets from Ledger Nano X on macOS
	allZeros := true
	for i := 0; i < len(buffer); i++ {
		if buffer[i] != 0 {
			allZeros = false
			break
		}
	}

	// Discard all zero packet
	if allZeros {
		// HID Returned Empty Packet - Retry Read
		continue
	}

	select {
	case ledger.readChannel <- buffer[:readBytes]:
		// Send data to UnwrapResponseAPDU
	default:
		// Possible source of bugs
		// Drop a buffer if ledger.readChannel is busy
	}
}

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant