From 5b7e24d744340345c11578911e3f1fa4ab0fb9cc Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 19 Jul 2005 08:25:39 +0000 Subject: * 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 --- sample/svr.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sample') diff --git a/sample/svr.rb b/sample/svr.rb index 6169861abc..11cfc5fbfe 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 -- cgit v1.2.3