Skip to content

Commit

Permalink
Remove Printlns from CallCMD
Browse files Browse the repository at this point in the history
We don't need it if we properly handle the result on the caller-side

Signed-off-by: Timo Klenk <[email protected]>
  • Loading branch information
kindlich committed May 5, 2022
1 parent 0cab0b4 commit 4dda56a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
12 changes: 6 additions & 6 deletions pkg/ephemeral/spdz.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ package ephemeral

import (
"context"
"errors"
"fmt"
d "github.com/carbynestack/ephemeral/pkg/discovery"
pb "github.com/carbynestack/ephemeral/pkg/discovery/transport/proto"
. "github.com/carbynestack/ephemeral/pkg/ephemeral/io"
"github.com/carbynestack/ephemeral/pkg/ephemeral/network"
. "github.com/carbynestack/ephemeral/pkg/types"
. "github.com/carbynestack/ephemeral/pkg/utils"
"sort"

"errors"
"fmt"
"io/ioutil"
"sort"
"strconv"
"time"

Expand Down Expand Up @@ -231,11 +230,12 @@ func (s *SPDZEngine) startMPC(ctx *CtxConfig) {
s.logger.Infow("Starting Player-Online.x", GameID, ctx.Act.GameID, "command", command)
stdout, stderr, err := s.cmder.CallCMD(ctx.Context, command, s.baseDir)
if err != nil {
s.logger.Errorw("Error while executing the user code", GameID, ctx.Act.GameID, "StdErr", string(stderr), "StdOut", string(stdout), "error", err)
err := fmt.Errorf("error while executing the user code: %v", err)
ctx.ErrCh <- err
s.logger.Errorw(err.Error(), GameID, ctx.Act.GameID)
} else {
s.logger.Debugw("Computation finished", GameID, ctx.Act.GameID, "StdErr", string(stderr), "StdOut", string(stdout))
}
s.logger.Debugw("Computation finished", GameID, ctx.Act.GameID, "StdErr", string(stderr), "StdOut", string(stdout), "error", err)
}

func (s *SPDZEngine) writeIPFile(path string, addr string, parties int32) error {
Expand Down
18 changes: 1 addition & 17 deletions pkg/utils/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"sync"
)

// Executor is an interface for calling a command and process its output.
Expand Down Expand Up @@ -69,21 +67,7 @@ func (c *Commander) CallCMD(ctx context.Context, cmd []string, dir string) ([]by
if err != nil {
return nil, nil, err
}

var waitGroup sync.WaitGroup
waitGroup.Add(1)
go func() {
// Check if the command finished successfully.
err = command.Wait()
defer waitGroup.Done()
if err != nil {
println(fmt.Sprintf("Error occured!"))
println(fmt.Sprintf("StdOut: %s", stdoutBuffer.Bytes()))
println(fmt.Sprintf("StdErr: %s", stderrBuffer.Bytes()))
}
}()
waitGroup.Wait()

err = command.Wait()
if err != nil {
switch err.(type) {
case *exec.ExitError:
Expand Down

0 comments on commit 4dda56a

Please sign in to comment.