Skip to content

Commit

Permalink
add per read / write accounting to socket layer
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13273 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 8, 2016
1 parent da3babb commit 1aef656
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/xpra/net/bytestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ def __init__(self, target, info):
self.target = target
self.info = info
self.input_bytecount = 0
self.input_readcount = 0
self.output_bytecount = 0
self.output_writecount = 0
self.filename = None #only used for unix domain sockets!
self.active = True
self.timeout = 0
Expand All @@ -187,13 +189,17 @@ def peek(self, n):
return None

def _write(self, *args):
""" wraps do_write with packet accounting """
w = self.untilConcludes(*args)
self.output_bytecount += w or 0
self.output_writecount += 1
return w

def _read(self, *args):
""" wraps do_read with packet accounting """
r = self.untilConcludes(*args)
self.input_bytecount += len(r or "")
self.input_readcount += 1
return r

def get_info(self):
Expand All @@ -202,8 +208,14 @@ def get_info(self):
"endpoint" : self.target or "",
"info" : self.info or "",
"active" : self.active,
"input.bytecount" : self.input_bytecount,
"output.bytecount" : self.output_bytecount,
"input" : {
"bytecount" : self.input_bytecount,
"readcount" : self.input_readcount,
},
"output" : {
"bytecount" : self.output_bytecount,
"writecount" : self.output_writecount,
},
}


Expand Down Expand Up @@ -267,8 +279,10 @@ def get_info(self):
d = Connection.get_info(self)
try:
d["type"] = "pipe"
d["pipe"] = {"read" : {"fd" : self._read_fd},
"write" : {"fd" : self._write_fd}}
d["pipe"] = {
"read" : {"fd" : self._read_fd},
"write" : {"fd" : self._write_fd},
}
except:
pass
return d
Expand Down

0 comments on commit 1aef656

Please sign in to comment.