Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: client/internal/logdog/butler/streamserver/npipe_windows.go

Issue 1429993002: LogDog: Add Butler stream server package. (Closed) Base URL: https://github.com/luci/luci-go@logdog-review-butlerproto
Patch Set: Cleanup, comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/internal/logdog/butler/streamserver/npipe_windows.go
diff --git a/client/internal/logdog/butler/streamserver/npipe_windows.go b/client/internal/logdog/butler/streamserver/npipe_windows.go
new file mode 100644
index 0000000000000000000000000000000000000000..135fbd27ba816672147b0a4a0ceb961aeff339a3
--- /dev/null
+++ b/client/internal/logdog/butler/streamserver/npipe_windows.go
@@ -0,0 +1,47 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package streamserver
+
+import (
+ "fmt"
+ "net"
+
+ log "github.com/luci/luci-go/common/logging"
+ "golang.org/x/net/context"
+ "gopkg.in/natefinch/npipe.v2"
+)
+
+type namedPipeServer struct {
+ namedPipeServerBase
+
+ address string // The address of the Windows socket to create
+}
+
+// NewNamedPipeServer instantiates a new POSIX named pipe server instance.
iannucci 2015/11/12 22:44:24 POSIX?
dnj 2015/11/13 20:17:15 Done.
+func NewNamedPipeServer(ctx context.Context, address string) StreamServer {
+ s := &namedPipeServer{
+ address: address,
+ }
+ ctx = log.SetField(ctx, "address", address)
+ s.initBase(ctx)
+ return s
+}
+
+func (s *namedPipeServer) String() string {
+ return fmt.Sprintf("NamedPipeServer[%s]", s.address)
iannucci 2015/11/12 22:44:24 we should distinguish these String()'s by somethin
dnj 2015/11/13 20:17:15 This was before logging, so I remove this altogeth
+}
+
+// Wrapper around the "unix"-type Listener that cleans up the named pipe on
+// creation and 'Close()'
+type selfCleaningUNIXListener struct {
+ path string
+ listener net.Listener
+}
+
+// OS-specific override to create a UNIX named socket listener
+func (s *namedPipeServer) createListener() (net.Listener, error) {
+ log.Debugf(s.ctx, "Creating Windows server socket Listener.")
+ return npipe.Listen(s.address)
+}

Powered by Google App Engine
This is Rietveld 408576698