summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:25:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:25:39 +0000
commit5b7e24d744340345c11578911e3f1fa4ab0fb9cc (patch)
treee91a96aa41166abd1bd8c531fb548999fde63869 /sample
parent0a5aab8679ca7d876f064f8fa1633d92a30cc346 (diff)
* io.c (rb_io_inspect): replace sprintf() with "%s" format all
over the place by snprintf() to avoid integer overflow. * sample/svr.rb: service can be stopped by ill-behaved client; use tsvr.rb instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/svr.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/sample/svr.rb b/sample/svr.rb
index 6169861..11cfc5f 100644
--- a/sample/svr.rb
+++ b/sample/svr.rb
@@ -1,6 +1,9 @@
# socket example - server side
# usage: ruby svr.rb
+# this server might be blocked by an ill-behaved client.
+# see tsvr.rb which is safe from client blocking.
+
require "socket"
gs = TCPserver.open(0)
@@ -22,10 +25,9 @@ loop do
print(s, " is gone\n")
s.close
socks.delete(s)
- else
- if str = s.gets
+ # single thread gets may block whole service
+ elsif str = s.gets
s.write(str)
- end
end
end
end