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

Unified Diff: examples/go/http_server.go

Issue 1374463002: Remove support for "all or none" two-phase data pipe read/write. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 months 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
« no previous file with comments | « no previous file | mojo/edk/system/core_unittest.cc » ('j') | mojo/public/platform/native_cgo/system_cgo.go » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/go/http_server.go
diff --git a/examples/go/http_server.go b/examples/go/http_server.go
index 2410e67409ed7c8c92ef64de7564ef919a44aa16..7c5ed4382853cbded3f1c40f98f51ac89738aab6 100644
--- a/examples/go/http_server.go
+++ b/examples/go/http_server.go
@@ -35,12 +35,12 @@ type MojoConnection struct {
// Implements net.Conn.
func (c *MojoConnection) Read(b []byte) (int, error) {
- l := len(b)
- r, read := c.receiveStream.BeginReadData(l, system.MOJO_READ_DATA_FLAG_NONE)
+ r, read := c.receiveStream.BeginReadData(system.MOJO_READ_DATA_FLAG_NONE)
if r != system.MOJO_RESULT_OK {
- return 0, fmt.Errorf("can't read %v bytes: %v", l, r)
+ return 0, fmt.Errorf("can't read: %v", r)
}
- if l > len(read) {
+ l := len(b)
+ if (l > len(read)) {
l = len(read)
}
copy(b, read[:l])
@@ -52,11 +52,11 @@ func (c *MojoConnection) Read(b []byte) (int, error) {
// Implements net.Conn.
func (c *MojoConnection) Write(b []byte) (int, error) {
- l := len(b)
- r, buf := c.sendStream.BeginWriteData(l, system.MOJO_WRITE_DATA_FLAG_NONE)
+ r, buf := c.sendStream.BeginWriteData(system.MOJO_WRITE_DATA_FLAG_NONE)
if r != system.MOJO_RESULT_OK {
- return 0, fmt.Errorf("can't write %v bytes: %v", l, r)
+ return 0, fmt.Errorf("can't write: %v", r)
}
+ l := len(b)
if l > len(buf) {
l = len(buf)
}
« no previous file with comments | « no previous file | mojo/edk/system/core_unittest.cc » ('j') | mojo/public/platform/native_cgo/system_cgo.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698