Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
8d9c2b2e
Commit
8d9c2b2e
authored
Feb 19, 2010
by
Petar Maymounkov
Committed by
Russ Cox
Feb 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add Pending method to ServerConn, ClientConn
R=rsc CC=golang-dev
https://golang.org/cl/216052
parent
666abfb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
persist.go
src/pkg/http/persist.go
+19
-1
No files found.
src/pkg/http/persist.go
View file @
8d9c2b2e
...
@@ -45,6 +45,8 @@ func NewServerConn(c net.Conn, r *bufio.Reader) *ServerConn {
...
@@ -45,6 +45,8 @@ func NewServerConn(c net.Conn, r *bufio.Reader) *ServerConn {
// called before Read has signaled the end of the keep-alive logic. The user
// called before Read has signaled the end of the keep-alive logic. The user
// should not call Close while Read or Write is in progress.
// should not call Close while Read or Write is in progress.
func
(
sc
*
ServerConn
)
Close
()
(
c
net
.
Conn
,
r
*
bufio
.
Reader
)
{
func
(
sc
*
ServerConn
)
Close
()
(
c
net
.
Conn
,
r
*
bufio
.
Reader
)
{
sc
.
lk
.
Lock
()
defer
sc
.
lk
.
Unlock
()
c
=
sc
.
c
c
=
sc
.
c
r
=
sc
.
r
r
=
sc
.
r
sc
.
c
=
nil
sc
.
c
=
nil
...
@@ -111,6 +113,14 @@ func (sc *ServerConn) Read() (req *Request, err os.Error) {
...
@@ -111,6 +113,14 @@ func (sc *ServerConn) Read() (req *Request, err os.Error) {
return
return
}
}
// Pending returns the number of unanswered requests
// that have been received on the connection.
func
(
sc
*
ServerConn
)
Pending
()
int
{
sc
.
lk
.
Lock
()
defer
sc
.
lk
.
Unlock
()
return
sc
.
nread
-
sc
.
nwritten
}
// Write writes a repsonse. To close the connection gracefully, set the
// Write writes a repsonse. To close the connection gracefully, set the
// Response.Close field to true. Write should be considered operational until
// Response.Close field to true. Write should be considered operational until
// it returns an error, regardless of any errors returned on the Read side.
// it returns an error, regardless of any errors returned on the Read side.
...
@@ -176,11 +186,11 @@ func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn {
...
@@ -176,11 +186,11 @@ func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn {
// called before the user or Read have signaled the end of the keep-alive
// called before the user or Read have signaled the end of the keep-alive
// logic. The user should not call Close while Read or Write is in progress.
// logic. The user should not call Close while Read or Write is in progress.
func
(
cc
*
ClientConn
)
Close
()
(
c
net
.
Conn
,
r
*
bufio
.
Reader
)
{
func
(
cc
*
ClientConn
)
Close
()
(
c
net
.
Conn
,
r
*
bufio
.
Reader
)
{
cc
.
lk
.
Lock
()
c
=
cc
.
c
c
=
cc
.
c
r
=
cc
.
r
r
=
cc
.
r
cc
.
c
=
nil
cc
.
c
=
nil
cc
.
r
=
nil
cc
.
r
=
nil
cc
.
lk
.
Lock
()
cc
.
reqm
.
Init
()
cc
.
reqm
.
Init
()
cc
.
lk
.
Unlock
()
cc
.
lk
.
Unlock
()
return
return
...
@@ -228,6 +238,14 @@ func (cc *ClientConn) Write(req *Request) os.Error {
...
@@ -228,6 +238,14 @@ func (cc *ClientConn) Write(req *Request) os.Error {
return
nil
return
nil
}
}
// Pending returns the number of unanswered requests
// that have been sent on the connection.
func
(
cc
*
ClientConn
)
Pending
()
int
{
cc
.
lk
.
Lock
()
defer
cc
.
lk
.
Unlock
()
return
cc
.
nwritten
-
cc
.
nread
}
// Read reads the next response from the wire. A valid response might be
// Read reads the next response from the wire. A valid response might be
// returned together with an ErrPersistEOF, which means that the remote
// returned together with an ErrPersistEOF, which means that the remote
// requested that this be the last request serviced. Read can be called
// requested that this be the last request serviced. Read can be called
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment