-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FdSet struct is platform specific depending on if we are on 32b or 64b platforms. We need to initialise it appropriately * Set timeout on select directly and remove unnecessary busy loop while waiting to read response from socket Signed-off-by: Mahendra Paipuri <[email protected]>
- Loading branch information
1 parent
2b63cef
commit 9134ba4
Showing
4 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//go:build 386 || mips || mipsle | ||
// +build 386 mips mipsle | ||
|
||
package ipmi | ||
|
||
import ( | ||
"time" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
// NFDBitS is the amount of bits per mask | ||
NFDBits = 4 * 8 | ||
) | ||
|
||
// FDZero set to zero the fdSet. | ||
func FDZero(p *unix.FdSet) { | ||
p.Bits = [32]int32{} | ||
} | ||
|
||
// timeval returns a pointer to unix.Timeval based on timeout value. | ||
func (t *timeout) timeval() *unix.Timeval { | ||
var timeoutS, timeoutUs time.Duration | ||
if t.value >= time.Second { | ||
timeoutS = t.value.Truncate(time.Second) | ||
timeoutUs = t.value - timeoutS | ||
} else { | ||
timeoutS = 0 | ||
timeoutUs = t.value | ||
} | ||
|
||
return &unix.Timeval{Sec: int32(timeoutS.Seconds()), Usec: int32(timeoutUs.Microseconds())} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//go:build amd64 || arm64 || mips64 || mips64le || ppc64le || riscv64 | ||
// +build amd64 arm64 mips64 mips64le ppc64le riscv64 | ||
|
||
package ipmi | ||
|
||
import ( | ||
"time" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
// NFDBitS is the amount of bits per mask. | ||
NFDBits = 8 * 8 | ||
) | ||
|
||
// FDZero set to zero the fdSet. | ||
func FDZero(p *unix.FdSet) { | ||
p.Bits = [16]int64{} | ||
} | ||
|
||
// timeval returns a pointer to unix.Timeval based on timeout value. | ||
func (t *timeout) timeval() *unix.Timeval { | ||
var timeoutS, timeoutUs time.Duration | ||
if t.value >= time.Second { | ||
timeoutS = t.value.Truncate(time.Second) | ||
timeoutUs = t.value - timeoutS | ||
} else { | ||
timeoutS = 0 | ||
timeoutUs = t.value | ||
} | ||
|
||
return &unix.Timeval{Sec: int64(timeoutS.Seconds()), Usec: timeoutUs.Microseconds()} | ||
} |