diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-07-13 09:46:45 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-07-13 09:46:45 +0000 |
commit | 84224545d924ce53af7d2fb53fccb079c4c63295 (patch) | |
tree | e9248e61e8315c5f2959421874cf3b6f4057452b | |
parent | 4428dd2a4ea288b881ec342f1155419a227340a5 (diff) | |
download | scala-84224545d924ce53af7d2fb53fccb079c4c63295.tar.gz scala-84224545d924ce53af7d2fb53fccb079c4c63295.tar.bz2 scala-84224545d924ce53af7d2fb53fccb079c4c63295.zip |
Fixed possible memory leak (bug 668).
-rw-r--r-- | src/actors/scala/actors/remote/TcpService.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index f3b928b4f2..d0944c3554 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -46,6 +46,8 @@ object TcpService { } portnum } + + var BufSize: int = 65536 } /* Class TcpService. @@ -61,6 +63,11 @@ class TcpService(port: Int) extends Thread with Service { private val pendingSends = new HashMap[Node, List[Array[byte]]] + /** + * Sends a byte array to another node on the network. + * If the node is not yet up, up to <code>TcpService.BufSize</code> + * messages are buffered. + */ def send(node: Node, data: Array[byte]): unit = synchronized { def bufferMsg(t: Throwable) = { @@ -69,7 +76,7 @@ class TcpService(port: Int) extends Thread with Service { pendingSends.get(node) match { case None => pendingSends += node -> (data :: Nil) - case Some(msgs) => + case Some(msgs) if msgs.length < TcpService.BufSize => pendingSends += node -> (data :: msgs) } } |