Commit Graph

86 Commits

Author SHA1 Message Date
misu a8d45c1b96 merge: master 2019-02-02 13:48:39 +09:00
kanozec 483fb8d7c3 Add "in bytes" to sizes in documentation 2018-10-30 07:45:53 -07:00
Steven Scott 3130e8d3f1 Return write buffer to pool on write error (#427)
Fix bug where connection did not return the write buffer to the pool
after a write error. Add test for the same.

Rename messsageWriter.fatal method to endMessage and consolidate all
message cleanup code there. This ensures that the buffer is returned to
pool on all code paths.

Rename Conn.prepMessage to beginMessage for symmetry with endMessage.
Move some duplicated code at calls to prepMessage to beginMessage.

Bonus improvement: Adjust message and buffer size in TestWriteBufferPool
to test that pool works with fragmented messages.
2018-09-24 16:26:12 -07:00
misu 6f489dbdf7 merge: v1.4.0 2018-09-11 17:52:11 +09:00
Steven Scott b378caee5b Add write buffer pooling
Add WriteBufferPool to Dialer and Upgrader. This field specifies a pool
to use for write operations on a connection.  Use of the pool can reduce
memory use when there is a modest write volume over a large number of
connections.

Use larger of hijacked buffer and buffer allocated for connection (if
any) as buffer for building handshake response. This decreases possible
allocations when building the handshake response.

Modify bufio reuse test to call Upgrade instead of the internal
newConnBRW. Move the test from conn_test.go to server_test.go because
it's a serer test.

Update newConn and newConnBRW:

- Move the bufio "hacks" from newConnBRW to separate functions and call
these functions directly from Upgrade.
- Rename newConn to newTestConn and move to conn_test.go. Shorten
argument list to common use case.
- Rename newConnBRW to newConn.
- Add pool code to newConn.
2018-08-22 14:11:59 -07:00
Adam Shannon 5fb94172f4 drop Go versions prior to 1.7 in CI
* drop Go versions prior to 1.7 in CI

* consolidate conn*.go files after dropping old Go support
2018-08-22 14:10:37 -07:00
misu e82d2a9ad7 mod: fmt 2018-04-23 11:29:20 +09:00
misu b27407e5fd mod: no need to change line feed 2018-04-20 10:07:26 +09:00
misu cd973fdcfc mod: pointed out part 2018-04-20 09:55:11 +09:00
Gary Burd eb92580837
Use net.Buffers to write multiple slices to connection
Closes #346.
2018-03-06 10:15:48 -08:00
misu af46d4fe1f mod: modification of review 2018-03-05 17:57:15 +09:00
misu f68770a434 mod: unnecessary format change 2018-02-09 10:16:19 +09:00
misu e9a52af44b mod: unnecessary format change 2018-02-09 10:13:43 +09:00
misu df2a0ccfb1 mod: comment 2018-02-07 11:02:34 +09:00
misu 1bf0779923 Merge branch 'master' into feature/context-takeover 2018-02-02 15:44:19 +09:00
misu 8e146c3b73 mod: remove unnecessary field 2018-02-01 19:04:12 +09:00
misu 7c6832cc73 mod: NextWriter if compress 2018-02-01 18:38:15 +09:00
misu 83a133897c mod: NextReader if compress 2018-02-01 18:34:03 +09:00
misu e7575e215d upgrade: compressContextTakeover reader 2018-02-01 18:26:02 +09:00
misu 3452ab8a61 mod: client & server setting for context-takeover 2018-02-01 14:57:00 +09:00
misu f8b4a0f71d mod: flate.writer for context-takeover 2018-02-01 12:59:30 +09:00
misu fb7d67a34a mod: fmt variables of conn.go 2018-02-01 11:56:17 +09:00
Gary Burd 4ac909741d
Improve control message handler doc
Fixes #338
2018-01-31 17:52:56 -08:00
misu ee46f8548a add: comment 2018-01-31 20:52:04 +09:00
misu fededdd187 mod: detach compressContextTakeover method and add debug comment. 2018-01-31 19:30:05 +09:00
misu 2472e6d800 upgrade: use pool for writerdict 2018-01-30 19:02:50 +09:00
misu e2dd00db3d mod: dict strategy 2018-01-29 15:10:19 +09:00
misu 80a809717d mod: add dict process 2018-01-25 13:55:52 +09:00
misu cecdf7ced4 mod: remove mutex. 2018-01-24 23:09:03 +09:00
misu eec63bf9bc mod: split dict to rx and tx 2018-01-24 18:08:43 +09:00
misu a366cdf616 impl: compressContextTakeover 2018-01-24 17:53:38 +09:00
misu 36c43970ee impl: decompressContextTakeover 2018-01-24 16:52:47 +09:00
Gary Burd 292fd08b25
Replace "frame" with "message" in documentation
The documentation sometimes used the term "frame" when referring to
single frame control messages.  Use the term "message" for consistency
in the documentation and to hide a detail that most application
programmers do not need to know about.
2018-01-10 06:15:25 -08:00
Gary Burd d965e9adc6
Handle no status in FormatCloseMessage
Return empty message for CloseNoStatusReceived. This status indicates
that the message is empty, so make it so. Because it's illegal to send
CloseNoStatusReceived, this change should not break a correct
application.
2017-12-28 07:29:59 -08:00
Gary Burd 23059f2957 Update with gofmt on tip
The changes are compatible with older versions of gofmt.
2017-11-23 00:11:29 -08:00
Gary Burd f918560c4c Improve NextWriter documentation 2017-10-10 09:16:43 -07:00
xPushkin c908dc801c Typo fix
Just a small typo fix.
2017-10-07 13:56:17 -07:00
Gary Burd b258b4fadb Use bufio.Writer returned from hijack in upgrade
Reuse the buffer backing the bufio.Writer returned from hijack if that
buffer is large enough to be generally useful and
Upgrader.WriteBufferSize == 0.

Update the logic for reusing bufio.Reader returned from hijack to match
the logic for bufio.Reader:  The buffer backing the reader must be
sufficiently large to be generally useful and Upgrader.ReadBufferSize ==
0.

Improve the documentation for ReadBufferSize and WriterBufferSize in
Dialer and Upgrader.
2017-03-02 14:46:13 -08:00
Gary Burd 4873052237 Fix formatting. 2017-03-01 09:42:05 -08:00
Gary Burd 286b5c9371 Use bufio.Reader returned from hijack in upgrade
Use the bufio.Reader returned from hijack if the reader's buffer size is
equal to the buffer size specified in Upgrader.ReadBufferSize.
2017-03-01 09:36:54 -08:00
Gary Burd 804cb600d0 Prepared Messages (#211) 2017-02-14 09:41:18 -08:00
Gary Burd 2257eda00b Fix compile error on Go < 1.6 2017-01-19 11:27:08 -08:00
Gary Burd b0dc45572b Change default and add API for compression level
Change the default compression level to 1. This level is faster and uses
less memory.

Add Conn.SetCompressionLevel API to allow applications to tune
compression on a per message basis.
2017-01-19 11:00:23 -08:00
Gary Burd bb547c6c5c Improve SetXHandler documentation 2017-01-15 13:09:21 -08:00
Gary Burd adf16b3178 Add safe maskBytes
Fixes #200.
2016-12-31 20:13:41 -08:00
Gary Burd 6c51b25bc8 Compression improvements
- Remove unnecessary error return from compressNoContextTakeover.
- Simplify use of sync.Pool.
- Fix formatting in compression documentation.
2016-12-27 17:05:16 -05:00
Cyrus Katrak 2db2f66488 pool flate readers 2016-12-19 07:28:05 -08:00
Gary Burd 0868951cdb Improve WriteMessage fast path
Restructure to avoid messageWriter allocation.
2016-12-07 16:21:58 -08:00
Gary Burd 9fbf129ff2 Add Conn.[Set]CloseHandler 2016-11-02 13:04:59 -07:00
Gary Burd 80a0029a65 Improve write error handling
- Do not fail NextWriter when close of previous writer fails.
- Replace closeSent field with mutex protected writeErr. Set writeErr on
  any error writing to underlying network connection. Check and return
  writeErr before attempting to write to network connection. Check
  writeErr in NextWriter so application can detect failed connection
  before attempting to write.
- Do not close underlying network connection on error.
- Move message writing state and method flushFrame from Conn to
  messageWriter. This makes error code paths (and the code in general)
  easier to understand.
- Add messageWriter field err to latch errors in messageWriter.

Bonus: Improve test coverage.
2016-11-02 09:59:14 -07:00