@cryptotaxi247 / kubo / commits / 9b1c99e9a

shrink msgio buffer size to decrease memory pressure

Jeromy committed Oct 28, 2014 at 00:28 UTC 9b1c99e9aaed5ad04b7c64369b87ae6ff320413d
3 files changed +15 -9
crypto/spipe/handshake.go
+8 -6
@@ -184,13 +184,15 @@ func (s *SecurePipe) handshake() error {
184 }
185
186 cmp := bytes.Compare(myPubKey, proposeResp.GetPubkey())
187 - mIV, tIV, mCKey, tCKey, mMKey, tMKey := ci.KeyStretcher(cmp, cipherType, hashType, secret)
188 - //ci.KeyStretcher(cmp, cipherType, hashType, secret)
187
190 - go s.handleSecureIn(hashType, cipherType, tIV, tCKey, tMKey)
191 - go s.handleSecureOut(hashType, cipherType, mIV, mCKey, mMKey)
188 + if true {
189 + mIV, tIV, mCKey, tCKey, mMKey, tMKey := ci.KeyStretcher(cmp, cipherType, hashType, secret)
190
193 - /*
191 + go s.handleSecureIn(hashType, cipherType, tIV, tCKey, tMKey)
192 + go s.handleSecureOut(hashType, cipherType, mIV, mCKey, mMKey)
193 +
194 + } else {
195 + log.Critical("Secure Channel Disabled! PLEASE ENSURE YOU KNOW WHAT YOU ARE DOING")
196 // Disable Secure Channel
197 go func(sp *SecurePipe) {
198 for {
@@ -220,7 +222,7 @@ func (s *SecurePipe) handshake() error {
222 }
223 }
224 }(s)
223 - */
225 + }
226
227 finished := []byte("Finished")
228
crypto/spipe/spipe_test.go
+1 -1
@@ -7,8 +7,8 @@ import (
7
8 ci "github.com/jbenet/go-ipfs/crypto"
9 "github.com/jbenet/go-ipfs/peer"
10 - "github.com/jbenet/go-ipfs/pipes"
10 "github.com/jbenet/go-ipfs/util"
11 + "github.com/jbenet/go-ipfs/util/pipes"
12 )
13
14 func getPeer(tb testing.TB) peer.Peer {
net/conn/conn.go
+6 -2
@@ -22,7 +22,7 @@ const (
22 ChanBuffer = 10
23
24 // MaxMessageSize is the size of the largest single message
25 - MaxMessageSize = 1 << 22 // 4 MB
25 + MaxMessageSize = 1 << 21 // 4 MB
26
27 // HandshakeTimeout for when nodes first connect
28 HandshakeTimeout = time.Second * 5
@@ -39,7 +39,11 @@ func init() {
39 }
40
41 func ReleaseBuffer(b []byte) {
42 - log.Warningf("Releasing buffer! (size = %d)", cap(b))
42 + log.Warningf("Releasing buffer! (cap,size = %d, %d)", cap(b), len(b))
43 + if cap(b) != MaxMessageSize {
44 + log.Warning("Release buffer failed.")
45 + return
46 + }
47 BufferPool.Put(b[:cap(b)])
48 }
49