[#41581] Ruby 1.6.7 dieing of segfault — Dossy <dossy@...>

I've got something that's fairly reproducible in 1.6.7. Is

11 messages 2002/06/02
[#41582] Re: Ruby 1.6.7 dieing of segfault — Nobuyoshi Nakada <nobu.nokada@...> 2002/06/02

Hi,

[#41660] dynamic attr_accessor?? — Markus Jais <mjais@...>

hello

16 messages 2002/06/03

[#41755] HTML Parser suggestions wanted — Ned Konz <ned@...>

I've written an HTML parser that builds trees from HTML source. After

13 messages 2002/06/04

[#41809] eval and local variable — "Park Heesob" <phasis@...>

15 messages 2002/06/05

[#41819] mod_ruby and module space — "Sean O'Dell" <sean@...>

It seems that if I execute a script using mod_ruby, I cannot call

18 messages 2002/06/05

[#41867] Pascal-like 'with' statement? — Philip Mak <pmak@...>

Is there something like Pascal's with statement? I'd like to turn this

18 messages 2002/06/06

[#41919] 1-second events — Paul Brannan <pbrannan@...>

I need to create an event that occurs exactly once per second.

15 messages 2002/06/06

[#42086] ANN: REXML 2.3.5 && 2.2.3 — Sean Russell <ser@...>

<posted & mailed>

31 messages 2002/06/09
[#42091] Re: ANN: REXML 2.3.5 && 2.2.3 — Sean Russell <ser@...> 2002/06/09

<posted & mailed>

[#42092] RE: ANN: REXML 2.3.5 && 2.2.3 — <james@...> 2002/06/09

> Well, XMLSchema may be troublesome to interpret, but it isn't

[#42192] ruby-dev summary 17252-17356 — Minero Aoki <aamine@...>

Hi all,

81 messages 2002/06/11
[#42290] Re: a new block parameter/variable notation (Re: ruby-dev summary 17252-17356) — Kent Dahl <kentda@...> 2002/06/12

Not wanting to flog a dead horse, but I just wonder what the final word

[#42295] Re: a new block parameter/variable notation (Re: ruby-dev summary 17252-17356) — matz@... (Yukihiro Matsumoto) 2002/06/12

Hi,

[#42455] Application server & web developement enviroment — "Radu M. Obad磚 <whizkid@...>

Howdy,

14 messages 2002/06/14
[#42459] Re: Application server & web developement enviroment — Austin Ziegler <austin@...> 2002/06/14

On Fri, 14 Jun 2002 15:55:31 +0900, Radu M. Obadwrote:

[#42472] ANN: Programmierung in Ruby — "Juergen Katins" <katins.juergen@...>

Programmierung in Ruby Online gibt es jetzt mit ausfrlichem

14 messages 2002/06/14

[#42504] Are Unix tools just slow? — Chris Gehlker <gehlker@...>

Awhile back I was asking for help with a unixy way to search the mounted

48 messages 2002/06/14
[#42516] Re: Are Unix tools just slow? — "Daniel P. Zepeda" <daniel@...> 2002/06/15

On Sat, 15 Jun 2002 07:14:38 +0900

[#42506] Re: Are Unix tools just slow? — Rick Bradley <rick@...> 2002/06/14

* Chris Gehlker (gehlker@fastq.com) [020614 17:18]:

[#42512] Re: Are Unix tools just slow? — Chris Gehlker <gehlker@...> 2002/06/15

On 6/14/02 3:34 PM, "Rick Bradley" <rick@rickbradley.com> wrote:

[#42513] opengl for ruby, please help — ccos <ccos@...> 2002/06/15

unix newby failing miserably here:

[#42507] mpg123 — Tobias Reif <tobiasreif@...>

Hi,

15 messages 2002/06/14

[#42546] File.new('foo', 0600 , 'wb') — Tobias Reif <tobiasreif@...>

Hi,

21 messages 2002/06/15
[#42552] Re: File.new('foo', 0600 , 'wb') — Tobias Reif <tobiasreif@...> 2002/06/15

Dossy wrote:

[#42591] Kernel#select questions — Wilkes Joiner <boognish23@...>

I'm trying to track down a bug where Kernel#select is returning [[],[],[]] as

12 messages 2002/06/17

[#42617] eRuby on Mac OS X — Jim Menard <jimm@...>

I've searched ruby-talk for this topic, and the only messages I found show

13 messages 2002/06/17

[#42674] REXML in C — "Radu M. Obad磚 <whizkid@...>

Hi,

20 messages 2002/06/18

[#42771] Why is I/O slow? — Clifford Heath <cjh_nospam@...>

Ok, folk, time to try again. It's nothing to do with SHA-1.

61 messages 2002/06/20
[#42831] Re: Why is I/O slow? — Clifford Heath <cjh_nospam@...> 2002/06/21

Yukihiro Matsumoto wrote:

[#42836] RE: Why is I/O slow? — "Mike Campbell" <michael_s_campbell@...> 2002/06/21

> With respect, this doesn't sound like a smart idea. The glibc folk have

[#42838] Re: Why is I/O slow? — Albert Wagner <alwagner@...> 2002/06/21

On Thursday 20 June 2002 10:10 pm, Mike Campbell wrote:

[#42839] Re: Why is I/O slow? — Austin Ziegler <austin@...> 2002/06/21

On Fri, 21 Jun 2002 12:16:24 +0900, Albert Wagner wrote:

[#42928] GOOD DEAL — "DR. ISA BELLO" <dr_isa@...>

FROM:DR ISA BELLO

11 messages 2002/06/22

[#42982] No exceptions from String#to_i — "Hal E. Fulton" <hal9000@...>

I've been bitten by this before... maybe

19 messages 2002/06/24
[#42983] Re: No exceptions from String#to_i — ts <decoux@...> 2002/06/24

>>>>> "H" == Hal E Fulton <hal9000@hypermetrics.com> writes:

[#42986] Re: No exceptions from String#to_i — Nikodemus Siivola <tsiivola@...> 2002/06/24

[#43122] Re: help (ruby-talk ML) — Benjamin Peterson <bjsp123@...>

20 messages 2002/06/27
[#43123] Re: help (ruby-talk ML) — Dave Thomas <Dave@...> 2002/06/27

Benjamin Peterson <bjsp123@yahoo.com> writes:

[#43124] RE: help (ruby-talk ML) — Bob Calco <robert.calco@...> 2002/06/27

Yes, I would gladly volunteer considerable effort to this end. I have

[#43147] Ruby on Mac OS X — Tobias Reif <tobiasreif@...>

Hi,

24 messages 2002/06/28

[#43174] eruby SAFE question — Dylan Northrup <docx@...>

I'm trying to implement a replacement for the standard apache file listings

39 messages 2002/06/28
[#43249] documentation licenses (was: eruby SAFE question) — Tobias Reif <tobiasreif@...> 2002/06/30

Dave Thomas wrote:

[#43250] Re: documentation licenses (was: eruby SAFE question) — Dave Thomas <Dave@...> 2002/06/30

Tobias Reif <tobiasreif@pinkjuice.com> writes:

[#43255] RE: documentation licenses (was: eruby SAFE question) — <james@...> 2002/06/30

>

[#43280] Re: documentation licenses (was: eruby SAFE question) — "Juergen Katins" <juergen.katins@...> 2002/07/01

Tobias Reif wrote

[#43282] Re: documentation licenses (was: eruby SAFE question) — David Alan Black <dblack@...> 2002/07/01

On Mon, 1 Jul 2002, Juergen Katins wrote:

[#43381] RE: documentation licenses (was: eruby SAFE question) — <james@...> 2002/07/02

> From: David Alan Black [mailto:dblack@candle.superlink.net]

Re: net/ftp is cpu bound on fast internet connections

From: Shugo Maeda <shugo@...>
Date: 2002-06-11 08:39:37 UTC
List: ruby-talk #42199
Hi,

> I was trying to run multiple ftp.putbinaryfile jobs and noticed that if 
> I run more than say 2 threads on my PIII 933, My CPU usage hits 100% and 
> my IO stays about the same, even though I am nowhere close to my 
> theorectical limit.  Here's the original code.
> 
> 1.upto(5) {|server_suffix|
>    puts "starting send to DL360#{server_suffix}"
>    threads[server_suffix] = Thread.new {
> 	ftp[server_suffix].putbinaryfile '100recs.tar.gz',
> 					 '100recs.tar.gz'
> 
>          telnet[server_suffix].cmd 'tar -xzf 100recs.tar.gz'
>    }
> }
> threads[1..5].each {|thread| thread.join}
> 
> My connection should actually be able to handle about 20 of these 
> threads at a time.  What I noticed was that of course ftp.rb's routines 
> are block oriented and pass everything through yield to a block for 
> processing.  I was wondering if it would be good for me or someone to 
> add non block-oriented functions that perhaps even memory map and or 
> buffer files where appropriate to save cpu time.

Can you try this patch?

Shugo

Index: lib/net/ftp.rb
===================================================================
RCS file: /src/ruby/lib/net/ftp.rb,v
retrieving revision 1.10
diff -u -r1.10 ftp.rb
--- lib/net/ftp.rb	2002/06/11 04:20:11	1.10
+++ lib/net/ftp.rb	2002/06/11 08:35:51
@@ -261,26 +261,21 @@
       @welcome = resp
     end
     
-    def retrbinary(cmd, blocksize, rest_offset = nil, callback = Proc.new)
+    def retrbinary(cmd, blocksize, rest_offset = nil)
       synchronize do
 	voidcmd("TYPE I")
 	conn = transfercmd(cmd, rest_offset)
 	loop do
 	  data = conn.read(blocksize)
 	  break if data == nil
-	  callback.call(data)
+	  yield(data)
 	end
 	conn.close
 	voidresp
       end
     end
     
-    def retrlines(cmd, callback = nil)
-      if block_given?
-	callback = Proc.new
-      elsif not callback.is_a?(Proc)
-	callback = Proc.new {|line| print line, "\n"}
-      end
+    def retrlines(cmd)
       synchronize do
 	voidcmd("TYPE A")
 	conn = transfercmd(cmd)
@@ -292,18 +287,14 @@
 	  elsif line[-1] == ?\n
 	    line = line[0 .. -2]
 	  end
-	  callback.call(line)
+	  yield(line)
 	end
 	conn.close
 	voidresp
       end
     end
     
-    def storbinary(cmd, file, blocksize, rest_offset = nil, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+    def storbinary(cmd, file, blocksize, rest_offset = nil, &block)
       synchronize do
 	voidcmd("TYPE I")
 	conn = transfercmd(cmd, rest_offset)
@@ -311,18 +302,14 @@
 	  buf = file.read(blocksize)
 	  break if buf == nil
 	  conn.write(buf)
-	  callback.call(buf) if use_callback
+	  yield(buf) if block
 	end
 	conn.close
 	voidresp
       end
     end
     
-    def storlines(cmd, file, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+    def storlines(cmd, file, &block)
       synchronize do
 	voidcmd("TYPE A")
 	conn = transfercmd(cmd)
@@ -333,7 +320,7 @@
 	    buf = buf.chomp + CRLF
 	  end
 	  conn.write(buf)
-	  callback.call(buf) if use_callback
+	  yield(buf) if block
 	end
 	conn.close
 	voidresp
@@ -341,11 +328,7 @@
     end
     
     def getbinaryfile(remotefile, localfile,
-		      blocksize = DEFAULT_BLOCKSIZE, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+		      blocksize = DEFAULT_BLOCKSIZE, &block)
       if @resume
 	rest_offset = File.size?(localfile)
 	f = open(localfile, "a")
@@ -357,24 +340,20 @@
 	f.binmode
 	retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
 	  f.write(data)
-	  callback.call(data) if use_callback
+	  yield(data) if block
 	end
       ensure
 	f.close
       end
     end
     
-    def gettextfile(remotefile, localfile, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+    def gettextfile(remotefile, localfile, &block)
       f = open(localfile, "w")
       begin
 	retrlines("RETR " + remotefile) do |line|
 	  line = line + @return_code
 	  f.write(line)
-	  callback.call(line) if use_callback
+	  yield(line) if block
 	end
       ensure
 	f.close
@@ -382,11 +361,7 @@
     end
     
     def putbinaryfile(localfile, remotefile,
-		      blocksize = DEFAULT_BLOCKSIZE, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+		      blocksize = DEFAULT_BLOCKSIZE, &block)
       if @resume
 	rest_offset = size(remotefile)
       else
@@ -395,24 +370,16 @@
       f = open(localfile)
       begin
 	f.binmode
-	storbinary("STOR " + remotefile, f, blocksize, rest_offset) do |data|
-	  callback.call(data) if use_callback
-	end
+	storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
       ensure
 	f.close
       end
     end
     
-    def puttextfile(localfile, remotefile, callback = nil)
-      if block_given?
-	callback = Proc.new
-      end
-      use_callback = callback.is_a?(Proc)
+    def puttextfile(localfile, remotefile, &block)
       f = open(localfile)
       begin
-	storlines("STOR " + remotefile, f) do |line|
-	  callback.call(line) if use_callback
-	end
+	storlines("STOR " + remotefile, f, &block)
       ensure
 	f.close
       end

In This Thread

Prev Next