-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOTE: all these follow-up commits will be squashed after the review is done. What changed in this commit: - refactor the code to make the dial retry logic be the same across platforms. - a number of code duplication fixes and refactors, raised by @jedevc Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
- Loading branch information
1 parent
414edfa
commit 630b062
Showing
9 changed files
with
198 additions
and
264 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 |
---|---|---|
@@ -1,33 +1,15 @@ | ||
package integration | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
"time" | ||
"net" | ||
|
||
"github.com/Microsoft/go-winio" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func waitSocket(address string, d time.Duration, cmd *exec.Cmd) error { | ||
address = strings.TrimPrefix(address, "npipe://") | ||
step := 50 * time.Millisecond | ||
i := 0 | ||
var socketScheme = "npipe://" | ||
|
||
for { | ||
if cmd != nil && cmd.ProcessState != nil { | ||
return errors.Errorf("process exited: %s", cmd.String()) | ||
} | ||
|
||
if conn, err := winio.DialPipe(address, nil); err == nil { | ||
conn.Close() | ||
break | ||
} | ||
i++ | ||
if time.Duration(i)*step > d { | ||
return errors.Errorf("failed dialing: %s", address) | ||
} | ||
time.Sleep(step) | ||
} | ||
return nil | ||
// abstracted function to handle pipe dialing on windows. | ||
// some simplification has been made to discard timeout param. | ||
func dialPipe(address string) (net.Conn, error) { | ||
return winio.DialPipe(address, nil) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.