Просмотр исходного кода

Merge branch 'v0.8'

* v0.8:
  Handle WANPPPConnection devices (fixes #431)
  Revert "Add temporary debug logging for #344 (revert later)"
  incomingIndexes should not be a package variable (fixes #344)
  Continue discovery on connect errors (fixes #324)

Conflicts:
	files/set.go
	model/model.go
	protocol/protocol.go
Jakob Borg 11 лет назад
Родитель
Сommit
797e53c5ba
1 измененных файлов с 26 добавлено и 26 удалено
  1. 26 26
      protocol/protocol.go

+ 26 - 26
protocol/protocol.go

@@ -11,7 +11,6 @@ import (
 	"io"
 	"io"
 	"sync"
 	"sync"
 	"time"
 	"time"
-
 	"github.com/calmh/syncthing/xdr"
 	"github.com/calmh/syncthing/xdr"
 )
 )
 
 
@@ -96,6 +95,15 @@ type rawConnection struct {
 	outbox chan []encodable
 	outbox chan []encodable
 	closed chan struct{}
 	closed chan struct{}
 	once   sync.Once
 	once   sync.Once
+
+	incomingIndexes chan incomingIndex
+}
+
+type incomingIndex struct {
+	update bool
+	id     NodeID
+	repo   string
+	files  []FileInfo
 }
 }
 
 
 type asyncResult struct {
 type asyncResult struct {
@@ -116,19 +124,20 @@ func NewConnection(nodeID NodeID, reader io.Reader, writer io.Writer, receiver M
 	wb := bufio.NewWriterSize(cw, 65536)
 	wb := bufio.NewWriterSize(cw, 65536)
 
 
 	c := rawConnection{
 	c := rawConnection{
-		id:       nodeID,
-		name:     name,
-		receiver: nativeModel{receiver},
-		state:    stateInitial,
-		cr:       cr,
-		xr:       xdr.NewReader(rb),
-		cw:       cw,
-		wb:       wb,
-		xw:       xdr.NewWriter(wb),
-		awaiting: make([]chan asyncResult, 0x1000),
-		outbox:   make(chan []encodable),
-		nextID:   make(chan int),
-		closed:   make(chan struct{}),
+		id:              nodeID,
+		name:            name,
+		receiver:        nativeModel{receiver},
+		state:           stateInitial,
+		cr:              cr,
+		xr:              xdr.NewReader(rb),
+		cw:              cw,
+		wb:              wb,
+		xw:              xdr.NewWriter(wb),
+		awaiting:        make([]chan asyncResult, 0x1000),
+		outbox:          make(chan []encodable),
+		nextID:          make(chan int),
+		closed:          make(chan struct{}),
+		incomingIndexes: make(chan incomingIndex, 100), // should be enough for anyone, right?
 	}
 	}
 
 
 	go c.indexSerializerLoop()
 	go c.indexSerializerLoop()
@@ -307,15 +316,6 @@ func (c *rawConnection) readerLoop() (err error) {
 	}
 	}
 }
 }
 
 
-type incomingIndex struct {
-	update bool
-	id     NodeID
-	repo   string
-	files  []FileInfo
-}
-
-var incomingIndexes = make(chan incomingIndex, 100) // should be enough for anyone, right?
-
 func (c *rawConnection) indexSerializerLoop() {
 func (c *rawConnection) indexSerializerLoop() {
 	// We must avoid blocking the reader loop when processing large indexes.
 	// We must avoid blocking the reader loop when processing large indexes.
 	// There is otherwise a potential deadlock where both sides has the model
 	// There is otherwise a potential deadlock where both sides has the model
@@ -325,7 +325,7 @@ func (c *rawConnection) indexSerializerLoop() {
 	// routine and buffered channel.
 	// routine and buffered channel.
 	for {
 	for {
 		select {
 		select {
-		case ii := <-incomingIndexes:
+		case ii := <-c.incomingIndexes:
 			if ii.update {
 			if ii.update {
 				if debug {
 				if debug {
 					l.Debugf("calling IndexUpdate(%v, %v, %d files)", ii.id, ii.repo, len(ii.files))
 					l.Debugf("calling IndexUpdate(%v, %v, %d files)", ii.id, ii.repo, len(ii.files))
@@ -360,7 +360,7 @@ func (c *rawConnection) handleIndex() error {
 		if debug {
 		if debug {
 			l.Debugf("queueing Index(%v, %v, %d files)", c.id, im.Repository, len(im.Files))
 			l.Debugf("queueing Index(%v, %v, %d files)", c.id, im.Repository, len(im.Files))
 		}
 		}
-		incomingIndexes <- incomingIndex{false, c.id, im.Repository, im.Files}
+		c.incomingIndexes <- incomingIndex{false, c.id, im.Repository, im.Files}
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -374,7 +374,7 @@ func (c *rawConnection) handleIndexUpdate() error {
 		if debug {
 		if debug {
 			l.Debugf("queueing IndexUpdate(%v, %v, %d files)", c.id, im.Repository, len(im.Files))
 			l.Debugf("queueing IndexUpdate(%v, %v, %d files)", c.id, im.Repository, len(im.Files))
 		}
 		}
-		incomingIndexes <- incomingIndex{true, c.id, im.Repository, im.Files}
+		c.incomingIndexes <- incomingIndex{true, c.id, im.Repository, im.Files}
 	}
 	}
 	return nil
 	return nil
 }
 }