public
Description: New and ultra-turbo-crazy-fast backend for Thin
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin-turbo.git
Search Repo:
Set timeout from Ruby
macournoyer (author)
Wed Apr 30 20:53:03 -0700 2008
commit  edab8a1dbcfcd9c70ab912423a69a5f5767dece6
tree    6da3857a454eeb9d7e6463d51d9c6e3234196609
parent  c1e069fc34f4a5964770375db8b938f4126aa435
0
...
1
2
...
 
1
0
@@ -1,3 +1,2 @@
0
-* Set timeout from Ruby
0
 * BUG: hangs on file upload 1 time out of 2
...
56
57
58
 
59
60
61
...
56
57
58
59
60
61
62
0
@@ -56,6 +56,7 @@
0
   DATA_GET(self, backend_t, backend);
0
   
0
   backend->app = rb_ivar_get(self, rb_intern("@app"));
0
+ backend->timeout = NUM2DBL(rb_ivar_get(self, rb_intern("@timeout")));
0
   backend->address = RSTRING_PTR(address);
0
   backend->port = FIX2INT(port);
0
   
...
112
113
114
 
115
116
117
...
172
173
174
175
176
177
178
179
...
112
113
114
115
116
117
118
...
173
174
175
 
 
176
177
178
0
@@ -112,6 +112,7 @@
0
   c->timeout_watcher.data = c;
0
   ev_io_init(&c->read_watcher, connection_readable_cb, c->fd, EV_READ);
0
   ev_io_init(&c->write_watcher, connection_writable_cb, c->fd, EV_WRITE);
0
+ ev_timer_init(&c->timeout_watcher, connection_timeout_cb, backend->timeout, backend->timeout);
0
   
0
   /* start event watchers */
0
   ev_timer_start(c->loop, &c->timeout_watcher);
0
@@ -172,8 +173,6 @@
0
     
0
     buffer_init(&c->read_buffer);
0
     buffer_init(&c->write_buffer);
0
-
0
- ev_timer_init(&c->timeout_watcher, connection_timeout_cb, CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);
0
     
0
     queue_push(&backend->connections, c);
0
   }
...
35
36
37
38
39
40
41
42
43
44
...
97
98
99
 
100
101
102
...
35
36
37
 
 
 
 
38
39
40
...
93
94
95
96
97
98
99
0
@@ -35,10 +35,6 @@
0
 /* initialize number of connections in the pool, will grow */
0
 #define CONNECTIONS_SIZE 100
0
 
0
-/* number of seconds before we give up reading/writing to a socket and close the connection
0
- * TODO make this configurable */
0
-#define CONNECTION_TIMEOUT 30.0
0
-
0
 /* when write buffer reach this size, it is sent right away, it controls the speed
0
  * at which a response is streamed. */
0
 #define STREAM_SIZE 1024
0
@@ -97,6 +93,7 @@
0
   size_t thread_count;
0
   
0
   /* libev */
0
+ ev_tstamp timeout;
0
   struct ev_loop *loop;
0
   ev_io accept_watcher;
0
   ev_idle idle_watcher;
...
26
27
28
29
30
 
 
 
31
32
33
...
26
27
28
 
 
29
30
31
32
33
34
0
@@ -26,8 +26,9 @@
0
       attr_accessor :persistent_connection_count
0
       
0
       def initialize(host, port, options={})
0
- @host = host
0
- @port = port.to_i
0
+ @host = host
0
+ @port = port.to_i
0
+ @timeout = 30
0
       end
0
       
0
       def start

Comments

    No one has commented yet.