ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
undoing even the last commit! it was too slow still!
Ryan Dahl (author)
2 months ago
commit  0a07adc53a3efabc3e20239a29163d86dd3c47b7
tree    cdfe1f3a96d5f7c361947818b8e8ad3f38edbf81
parent  b128ee31d3751baae5229187a8f6ad865dba63d1
...
51
52
53
 
 
 
54
55
56
...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
 
 
 
 
91
92
93
 
94
95
96
...
51
52
53
54
55
56
57
58
59
...
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
76
77
78
79
80
81
82
83
84
0
@@ -51,6 +51,9 @@ VALUE server_listen_on_port(VALUE _, VALUE port)
0
   return Qnil;
0
 }
0
 
0
+static void
0
+oneshot_timeout (struct ev_loop *loop, struct ev_timer *w, int revents) {;}
0
+
0
 VALUE server_process_connections(VALUE _)
0
 {
0
   /* This function is super hacky. The libev loop is called for one iteration
0
@@ -67,30 +70,15 @@ VALUE server_process_connections(VALUE _)
0
    * clients are in_use? Whatever happens here, one should make sure the
0
    * 'wait' benchmark is running as quickly with Ebb as it does with mongrel.
0
    */
0
-
0
- int i;
0
- int running_clients = FALSE;
0
- for(i = 0; i < EBB_MAX_CLIENTS; i++)
0
- if(server->clients[i].open) {
0
- running_clients = TRUE;
0
- break;
0
- }
0
- if(!running_clients) {
0
- fd_set fds;
0
- struct timeval tv = { tv_sec: 1, tv_usec: 0 };
0
- FD_ZERO(&fds);
0
- FD_SET(server->fd, &fds);
0
- /* sit in ruby thread select for a second when there are no connections */
0
- rb_thread_select(server->fd+1, &fds, &fds, &fds, &tv);
0
- }
0
-
0
- if(!server->open)
0
- return Qnil;
0
-
0
- ev_loop(loop, EVLOOP_NONBLOCK);
0
+ ev_timer timeout;
0
+ ev_timer_init (&timeout, oneshot_timeout, 0.1, 0.);
0
+ ev_timer_start (loop, &timeout);
0
+ ev_loop(loop, EVLOOP_ONESHOT);
0
+ ev_timer_stop(loop, &timeout);
0
   
0
   /* Call rb_thread_schedule() proportional to the number of rb threads running */
0
   /* SO HACKY! Anyone have a better way to do this? */
0
+ int i;
0
   for(i = 0; i < EBB_MAX_CLIENTS; i++)
0
     if(server->clients[i].in_use)
0
       rb_thread_schedule();

Comments

    No one has commented yet.