Skip to content

Commit 4d8b257

Browse files
committed
Merge branch 'readclose' into apps
2 parents b6e6d7b + 46b24f7 commit 4d8b257

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

coderd/coderd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func New(options *Options) *API {
102102
httpmw.RateLimitPerMinute(options.APIRateLimit),
103103
apiKeyMiddleware,
104104
httpmw.ExtractUserParam(api.Database),
105-
authRolesMiddleware,
106105
)
107106
r.Get("/*", api.workspaceAppsProxyPath)
108107
})

provisionersdk/serve.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func Serve(ctx context.Context, server proto.DRPCProvisionerServer, options *Ser
3232
config := yamux.DefaultConfig()
3333
config.LogOutput = io.Discard
3434
stdio, err := yamux.Server(&readWriteCloser{
35-
ReadCloser: os.Stdin,
36-
WriteCloser: os.Stdout,
35+
ReadCloser: os.Stdin,
36+
Writer: os.Stdout,
3737
}, config)
3838
if err != nil {
3939
return xerrors.Errorf("create yamux: %w", err)
@@ -70,3 +70,8 @@ func Serve(ctx context.Context, server proto.DRPCProvisionerServer, options *Ser
7070
}
7171
return nil
7272
}
73+
74+
type readWriteCloser struct {
75+
io.ReadCloser
76+
io.Writer
77+
}

provisionersdk/transport.go

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package provisionersdk
33
import (
44
"context"
55
"io"
6-
"sync"
6+
"net"
77

88
"github.com/hashicorp/yamux"
99
"storj.io/drpc"
@@ -18,22 +18,14 @@ const (
1818

1919
// TransportPipe creates an in-memory pipe for dRPC transport.
2020
func TransportPipe() (*yamux.Session, *yamux.Session) {
21-
clientReader, clientWriter := io.Pipe()
22-
serverReader, serverWriter := io.Pipe()
21+
c1, c2 := net.Pipe()
2322
yamuxConfig := yamux.DefaultConfig()
2423
yamuxConfig.LogOutput = io.Discard
25-
client, err := yamux.Client(&readWriteCloser{
26-
ReadCloser: clientReader,
27-
WriteCloser: serverWriter,
28-
}, yamuxConfig)
24+
client, err := yamux.Client(c1, yamuxConfig)
2925
if err != nil {
3026
panic(err)
3127
}
32-
33-
server, err := yamux.Server(&readWriteCloser{
34-
ReadCloser: serverReader,
35-
WriteCloser: clientWriter,
36-
}, yamuxConfig)
28+
server, err := yamux.Server(c2, yamuxConfig)
3729
if err != nil {
3830
panic(err)
3931
}
@@ -45,22 +37,6 @@ func Conn(session *yamux.Session) drpc.Conn {
4537
return &multiplexedDRPC{session}
4638
}
4739

48-
type readWriteCloser struct {
49-
closeMutex sync.Mutex
50-
io.ReadCloser
51-
io.WriteCloser
52-
}
53-
54-
func (c *readWriteCloser) Close() error {
55-
c.closeMutex.Lock()
56-
defer c.closeMutex.Unlock()
57-
err := c.ReadCloser.Close()
58-
if err != nil {
59-
return err
60-
}
61-
return c.WriteCloser.Close()
62-
}
63-
6440
// Allows concurrent requests on a single dRPC connection.
6541
// Required for calling functions concurrently.
6642
type multiplexedDRPC struct {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy