GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Beanstalkd is a fast, distributed, in-memory workqueue service. Its interface is generic, but was designed for use in reducing the latency of page views in high-volume web applications by running most time-consuming tasks asynchronously.
Homepage: http://xph.us/software/beanstalkd/
Clone URL: git://github.com/kr/beanstalkd.git
Click here to lend your support to: beanstalkd and make a donation at www.pledgie.com !
Avoid a soonest_job call when we know we're timing out by request.
dustin (author)
Sat Jun 07 16:04:36 -0700 2008
commit  1ca60f54006364ee7f002603b8324c34906951c6
tree    4b5bb8f53f16c9fc4f96cd687434e9d0a415a944
parent  261845d35429fda45636230886a8528207c57a18
0
...
149
150
151
152
 
153
154
155
156
157
158
 
 
 
 
 
159
160
161
162
163
164
165
166
167
168
169
...
149
150
151
 
152
153
154
155
156
157
 
158
159
160
161
162
163
164
165
166
 
 
 
 
167
168
169
0
@@ -149,21 +149,21 @@ has_reserved_job(conn c)
0
 int
0
 conn_set_evq(conn c, const int events, evh handler)
0
 {
0
- int r, margin = 0, should_timeout=0;
0
+ int r, margin = 0, should_timeout = 0;
0
     struct timeval tv = {INT_MAX, 0};
0
 
0
     event_set(&c->evq, c->fd, events, handler, c);
0
 
0
     if (conn_waiting(c)) margin = 1;
0
- if (has_reserved_job(c)) {
0
+ if (c->pending_timeout >= 0) {
0
+ tv.tv_sec = c->pending_timeout;
0
+ should_timeout=1;
0
+ }
0
+ if (should_timeout == 0 && has_reserved_job(c)) {
0
         time_t t = soonest_job(c)->deadline - time(NULL) - margin;
0
         tv.tv_sec = t > 0 ? t : 0;
0
         should_timeout = 1;
0
     }
0
- if (c->pending_timeout >= 0) {
0
- tv.tv_sec = min(tv.tv_sec, c->pending_timeout);
0
- should_timeout = 1;
0
- }
0
 
0
     r = event_add(&c->evq, should_timeout ? &tv : NULL);
0
     if (r == -1) return twarn("event_add() err %d", errno), -1;

Comments

    No one has commented yet.