public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Instrumenting more code to hunt down potential mem leaks w/ bleakhouse.
macournoyer (author)
Sat Feb 09 22:30:55 -0800 2008
commit  12c8b5a3b699af419ea210b8496f915956617e01
tree    b025e248a10bd1888e984d4cec10322426bc8b7a
parent  d6d9661620f37b5060631aa592c57374cafd0e25
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
 ext/thin_parser/*.so
0
 lib/*.bundle
0
 lib/*.so
0
-log/*.log
0
+loglog
0
 spec/rails_app/log
0
 doc/rdoc/*
0
 tmp/*
...
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
13
14
15
16
 
 
17
18
19
 
 
 
 
 
20
21
22
23
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
26
27
...
29
30
31
 
32
33
34
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
 
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
76
77
78
79
80
81
82
0
@@ -8,20 +8,67 @@
0
 # bleak log/memlog
0
 #
0
 
0
+module Kernel
0
+ def alias_method_chain(target, feature)
0
+ # Strip out punctuation on predicates or bang methods since
0
+ # e.g. target?_without_feature is not a valid method name.
0
+ aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
0
+ yield(aliased_target, punctuation) if block_given?
0
+
0
+ with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
0
+
0
+ alias_method without_method, target
0
+ alias_method target, with_method
0
+
0
+ case
0
+ when public_method_defined?(without_method)
0
+ public target
0
+ when protected_method_defined?(without_method)
0
+ protected target
0
+ when private_method_defined?(without_method)
0
+ private target
0
+ end
0
+ end
0
+end
0
+
0
 module BleakInstruments
0
   module Connection
0
     def self.included(base)
0
       base.class_eval do
0
- alias_method :process_without_instrument, :process
0
- alias_method :process, :process_with_instrument
0
+ alias_method_chain :receive_data, :instrument
0
+ alias_method_chain :process, :instrument
0
       end
0
     end
0
     
0
+ def receive_data_with_instrument(data)
0
+ receive_data_without_instrument(data)
0
+ $memlogger.snapshot($logfile, "connection/receive_data", false, 0.1)
0
+ end
0
+
0
     def process_with_instrument
0
       process_without_instrument
0
       $memlogger.snapshot($logfile, "connection/process", false, 0.1)
0
     end
0
   end
0
+
0
+ module Connector
0
+ def self.included(base)
0
+ base.class_eval do
0
+ alias_method_chain :connect, :instrument
0
+ alias_method_chain :initialize_connection, :instrument
0
+ end
0
+ end
0
+
0
+ def connect_with_instrument
0
+ connect_without_instrument
0
+ $memlogger.snapshot($logfile, "connector/connect", false, 0.1)
0
+ end
0
+
0
+ def initialize_connection_with_instrument(connection)
0
+ initialize_connection_without_instrument(connection)
0
+ $memlogger.snapshot($logfile, "connector/initialize_connection", false, 0.1)
0
+ end
0
+ end
0
 end
0
 
0
 require 'rubygems'
0
@@ -29,6 +76,7 @@
0
 require File.dirname(__FILE__) + '/../lib/thin'
0
 
0
 Thin::Connection.send :include, BleakInstruments::Connection
0
+Thin::Connectors::TcpServer.send :include, BleakInstruments::Connector
0
 
0
 $memlogger = BleakHouse::Logger.new
0
 File.delete($logfile = File.expand_path("log/memlog")) rescue nil

Comments

    No one has commented yet.