2
0
Fork 0

Add wrk in vrequest, s/vr->con->wrk/vr->wrk/, removed some other (broken) usages of vr->con

This commit is contained in:
Stefan Bühler 2009-04-15 12:34:06 +02:00
parent 4e04ac6b8b
commit 595ce1fe13
15 changed files with 64 additions and 62 deletions

View File

@ -39,13 +39,13 @@ LI_API const char *remove_path(const char *path);
log_split_lines_(srv, vr, LOG_LEVEL_BACKEND, LOG_FLAG_TIMESTAMP, txt, "(backend) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define VR_SEGFAULT(vr, fmt, ...) _SEGFAULT(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_ERROR(vr, fmt, ...) _ERROR(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_WARNING(vr, fmt, ...) _WARNING(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_INFO(vr, fmt, ...) _INFO(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_DEBUG(vr, fmt, ...) _DEBUG(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_BACKEND(vr, fmt, ...) _BACKEND(vr->con->srv, vr, fmt, __VA_ARGS__)
#define VR_BACKEND_LINES(vr, txt, fmt, ...) _BACKEND_LINES(vr->con->srv, vr, txt, fmt, __VA_ARGS__)
#define VR_SEGFAULT(vr, fmt, ...) _SEGFAULT(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_ERROR(vr, fmt, ...) _ERROR(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_WARNING(vr, fmt, ...) _WARNING(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_INFO(vr, fmt, ...) _INFO(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_DEBUG(vr, fmt, ...) _DEBUG(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_BACKEND(vr, fmt, ...) _BACKEND(vr->wrk->srv, vr, fmt, __VA_ARGS__)
#define VR_BACKEND_LINES(vr, txt, fmt, ...) _BACKEND_LINES(vr->wrk->srv, vr, txt, fmt, __VA_ARGS__)
#define SEGFAULT(srv, fmt, ...) _SEGFAULT(srv, NULL, fmt, __VA_ARGS__)
#define ERROR(srv, fmt, ...) _ERROR(srv, NULL, fmt, __VA_ARGS__)

View File

@ -57,6 +57,7 @@ struct vrequest_ref {
struct vrequest {
connection *con;
worker *wrk;
vrequest_ref *ref;
option_value *options;

View File

@ -145,7 +145,7 @@ void action_stack_init(action_stack *as) {
}
void action_stack_reset(vrequest *vr, action_stack *as) {
server *srv = vr->con->srv;
server *srv = vr->wrk->srv;
guint i;
for (i = as->stack->len; i-- > 0; ) {
action_stack_element_release(srv, vr, &g_array_index(as->stack, action_stack_element, i));
@ -155,7 +155,7 @@ void action_stack_reset(vrequest *vr, action_stack *as) {
}
void action_stack_clear(vrequest *vr, action_stack *as) {
server *srv = vr->con->srv;
server *srv = vr->wrk->srv;
guint i;
for (i = as->stack->len; i-- > 0; ) {
action_stack_element_release(srv, vr, &g_array_index(as->stack, action_stack_element, i));
@ -189,7 +189,7 @@ handler_t action_execute(vrequest *vr) {
action_stack_element *ase;
handler_t res;
gboolean condres;
server *srv = vr->con->srv;
server *srv = vr->wrk->srv;
while (NULL != (ase = action_stack_top(as))) {
if (as->backend_failed) {
@ -236,7 +236,7 @@ handler_t action_execute(vrequest *vr) {
continue;
}
vr->con->wrk->stats.actions_executed++;
vr->wrk->stats.actions_executed++;
a = ase->act;
switch (a->type) {

View File

@ -52,7 +52,7 @@ handler_t chunkfile_open(vrequest *vr, chunkfile *cf) {
}
if (-1 == (cf->fd = open(cf->name->str, O_RDONLY))) {
if (EMFILE == errno) {
server_out_of_fds(vr->con->srv);
server_out_of_fds(vr->wrk->srv);
}
VR_ERROR(vr, "Couldn't open file '%s': %s", GSTR_SAFE_STR(cf->name), g_strerror(errno));
return HANDLER_ERROR;
@ -361,7 +361,7 @@ void cqlimit_release(cqlimit *cql) {
static void cqlimit_lock(cqlimit *cql) {
cql->locked = TRUE;
if (cql->io_watcher && cql->io_watcher->fd != -1) {
ev_io_rem_events(cql->vr->con->wrk->loop, cql->io_watcher, EV_READ);
ev_io_rem_events(cql->vr->wrk->loop, cql->io_watcher, EV_READ);
}
if (cql->notify) {
cql->notify(cql->vr, cql->context, cql->locked);
@ -371,7 +371,7 @@ static void cqlimit_lock(cqlimit *cql) {
static void cqlimit_unlock(cqlimit *cql) {
cql->locked = FALSE;
if (cql->io_watcher && cql->io_watcher->fd != -1) {
ev_io_add_events(cql->vr->con->wrk->loop, cql->io_watcher, EV_READ);
ev_io_add_events(cql->vr->wrk->loop, cql->io_watcher, EV_READ);
}
if (cql->notify) {
cql->notify(cql->vr, cql->context, cql->locked);

View File

@ -108,7 +108,7 @@ void etag_mutate(GString *mut, GString *etag) {
void etag_set_header(vrequest *vr, struct stat *st, gboolean *cachable) {
guint flags = CORE_OPTION(CORE_OPTION_ETAG_FLAGS).number;
GString *tmp_str = vr->con->wrk->tmp_str;
GString *tmp_str = vr->wrk->tmp_str;
struct tm tm;
tristate_t c_able = cachable ? TRI_MAYBE : TRI_FALSE;

View File

@ -49,7 +49,7 @@ gboolean log_write_(server *srv, vrequest *vr, log_level_t log_level, guint flag
if (vr != NULL) {
if (!srv) srv = vr->con->srv;
if (!srv) srv = vr->wrk->srv;
/* get log from connection */
log = g_array_index(CORE_OPTION(CORE_OPTION_LOG).list, log_t*, log_level);
if (log == NULL)
@ -102,7 +102,7 @@ gboolean log_write_(server *srv, vrequest *vr, log_level_t log_level, guint flag
/* if we have a worker context, we can use its timestamp to save us a call to time() */
if (vr != NULL)
cur_ts = (time_t)CUR_TS(vr->con->wrk);
cur_ts = (time_t)CUR_TS(vr->wrk);
else
cur_ts = time(NULL);

View File

@ -233,7 +233,7 @@ static handler_t cache_etag_handle(vrequest *vr, gpointer param, gpointer *conte
GList *etag_entry;
http_header *etag;
struct stat st;
GString *tmp_str = vr->con->wrk->tmp_str;
GString *tmp_str = vr->wrk->tmp_str;
if (!cfile) {
if (vr->request.http_method != HTTP_METHOD_GET) return HANDLER_GO_ON;
@ -265,7 +265,7 @@ static handler_t cache_etag_handle(vrequest *vr, gpointer param, gpointer *conte
}
if (-1 == (cfile->hit_fd = open(cfile->filename->str, O_RDONLY))) {
if (EMFILE == errno) {
server_out_of_fds(vr->con->srv);
server_out_of_fds(vr->wrk->srv);
}
VR_ERROR(vr, "Couldn't open cache file '%s': %s", cfile->filename->str, g_strerror(errno));
return HANDLER_GO_ON; /* no caching */

View File

@ -204,8 +204,8 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
GString *duration = g_string_sized_new(15);
g_string_append_printf(html, "<p>now: %f<br>io timeout watcher active/repeat: %s/%f<br></p>\n",
CUR_TS(vr->con->wrk), ev_is_active(&(vr->con->wrk->io_timeout_queue.timer)) ? "yes":"no",
vr->con->wrk->io_timeout_queue.timer.repeat
CUR_TS(vr->wrk), ev_is_active(&(vr->wrk->io_timeout_queue.timer)) ? "yes":"no",
vr->wrk->io_timeout_queue.timer.repeat
);
g_string_append_len(html, CONST_STR_LEN("<table><tr><th>Client</th><th>Duration</th><th></th></tr>\n"));
@ -216,7 +216,7 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
for (j = 0; j < cons->len; j++) {
mod_debug_data_t *d = &g_array_index(cons, mod_debug_data_t, j);
counter_format((guint64)(CUR_TS(vr->con->wrk) - d->ts), COUNTER_TIME, duration);
counter_format((guint64)(CUR_TS(vr->wrk) - d->ts), COUNTER_TIME, duration);
g_string_append_printf(html, "<tr><td>%s</td><td style=\"text-align:right;\">%s</td><td style=\"padding-left:10px;\"><a href=\"?%u_%u_%d_%s\">debug</a></td></tr>\n",
d->remote_addr_str->str,
duration->str,
@ -244,7 +244,7 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
g_string_append_len(html, CONST_STR_LEN("</body>\n</html>\n"));
chunkqueue_append_string(vr->con->out, html);
chunkqueue_append_string(vr->out, html);
http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
vr->response.http_status = 200;
vrequest_joblist_append(vr);
@ -283,7 +283,7 @@ static handler_t debug_show_connections(vrequest *vr, gpointer param, gpointer *
VR_DEBUG(vr, "%s", "collecting debug info...");
ci = collect_start(vr->con->wrk, debug_collect_func, j, debug_collect_cb, j);
ci = collect_start(vr->wrk, debug_collect_func, j, debug_collect_cb, j);
*context = ci; /* may be NULL */
}
@ -341,4 +341,4 @@ gboolean mod_debug_free(modules *mods, module *mod) {
plugin_free(mods->main, mod->config);
return TRUE;
}
}

View File

@ -597,4 +597,4 @@ gboolean mod_dirlist_free(modules *mods, module *mod) {
plugin_free(mods->main, mod->config);
return TRUE;
}
}

View File

@ -189,7 +189,7 @@ static void fastcgi_connection_free(fastcgi_connection *fcon) {
if (!fcon) return;
vr = fcon->vr;
ev_io_stop(vr->con->wrk->loop, &fcon->fd_watcher);
ev_io_stop(vr->wrk->loop, &fcon->fd_watcher);
fastcgi_context_release(fcon->ctx);
if (fcon->fd != -1) close(fcon->fd);
@ -427,7 +427,7 @@ static void fastcgi_send_env(vrequest *vr, fastcgi_connection *fcon) {
{
GList *i;
GString *tmp = vr->con->wrk->tmp_str;
GString *tmp = vr->wrk->tmp_str;
for (i = vr->request.headers->entries.head; NULL != i; i = i->next) {
http_header *h = (http_header*) i->data;
@ -462,7 +462,7 @@ static void fastcgi_send_env(vrequest *vr, fastcgi_connection *fcon) {
static void fastcgi_forward_request(vrequest *vr, fastcgi_connection *fcon) {
stream_send_chunks(fcon->fcgi_out, FCGI_STDIN, fcon->requestid, vr->in);
if (fcon->fcgi_out->length > 0)
ev_io_add_events(vr->con->wrk->loop, &fcon->fd_watcher, EV_WRITE);
ev_io_add_events(vr->wrk->loop, &fcon->fd_watcher, EV_WRITE);
}
static gboolean fastcgi_get_packet(fastcgi_connection *fcon) {
@ -535,11 +535,11 @@ static gboolean fastcgi_parse_response(fastcgi_connection *fcon) {
break;
case FCGI_STDERR:
len = fastcgi_available(fcon);
chunkqueue_extract_to(vr, fcon->fcgi_in, len, vr->con->wrk->tmp_str);
chunkqueue_extract_to(vr, fcon->fcgi_in, len, vr->wrk->tmp_str);
if (FASTCGI_OPTION(FASTCGI_OPTION_LOG_PLAIN_ERRORS).boolean) {
log_split_lines(vr->con->srv, vr, LOG_LEVEL_BACKEND, 0, vr->con->wrk->tmp_str->str, "");
log_split_lines(vr->wrk->srv, vr, LOG_LEVEL_BACKEND, 0, vr->wrk->tmp_str->str, "");
} else {
VR_BACKEND_LINES(vr, vr->con->wrk->tmp_str->str, "%s", "(fcgi-stderr) ");
VR_BACKEND_LINES(vr, vr->wrk->tmp_str->str, "%s", "(fcgi-stderr) ");
}
chunkqueue_skip(fcon->fcgi_in, len);
break;
@ -665,14 +665,14 @@ static handler_t fastcgi_statemachine(vrequest *vr, fastcgi_connection *fcon) {
} while (-1 == fcon->fd && errno == EINTR);
if (-1 == fcon->fd) {
if (errno == EMFILE) {
server_out_of_fds(vr->con->srv);
server_out_of_fds(vr->wrk->srv);
}
VR_ERROR(vr, "Couldn't open socket: %s", g_strerror(errno));
return HANDLER_ERROR;
}
fd_init(fcon->fd);
ev_io_set(&fcon->fd_watcher, fcon->fd, EV_READ | EV_WRITE);
ev_io_start(vr->con->wrk->loop, &fcon->fd_watcher);
ev_io_start(vr->wrk->loop, &fcon->fd_watcher);
/* fall through */
case FS_CONNECTING:
@ -689,7 +689,7 @@ static handler_t fastcgi_statemachine(vrequest *vr, fastcgi_connection *fcon) {
return HANDLER_GO_ON;
default:
VR_ERROR(vr, "Couldn't connect to '%s': %s",
sockaddr_to_string(fcon->ctx->socket, vr->con->wrk->tmp_str, TRUE)->str,
sockaddr_to_string(fcon->ctx->socket, vr->wrk->tmp_str, TRUE)->str,
g_strerror(errno));
fastcgi_close(vr, p);
vrequest_backend_dead(vr);

View File

@ -276,7 +276,7 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
0, 0, G_GUINT64_CONSTANT(0), 0, 0
};
uptime = CUR_TS(vr->con->wrk) - vr->con->srv->started;
uptime = CUR_TS(vr->wrk) - vr->wrk->srv->started;
if (!uptime)
uptime = 1;
@ -321,11 +321,11 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
" <body>\n"
));
counter_format((guint64)(CUR_TS(vr->con->wrk) - vr->con->srv->started), COUNTER_TIME, tmpstr);
counter_format((guint64)(CUR_TS(vr->wrk) - vr->wrk->srv->started), COUNTER_TIME, tmpstr);
g_string_append_printf(html, html_top,
vr->request.uri.host->str,
tmpstr->str,
vr->con->srv->started_str->str
vr->wrk->srv->started_str->str
);
@ -480,7 +480,7 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
for (j = 0; j < sd->connections->len; j++) {
mod_status_con_data *cd = &g_array_index(sd->connections, mod_status_con_data, j);
counter_format((guint64)(CUR_TS(vr->con->wrk) - cd->ts), COUNTER_TIME, ts);
counter_format((guint64)(CUR_TS(vr->wrk) - cd->ts), COUNTER_TIME, ts);
counter_format(cd->bytes_in, COUNTER_BYTES, bytes_in);
counter_format(cd->bytes_in_5s_diff / G_GUINT64_CONSTANT(5), COUNTER_BYTES, bytes_in_5s);
counter_format(cd->bytes_out, COUNTER_BYTES, bytes_out);
@ -536,7 +536,7 @@ static void status_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result
" </body>\n"
"</html>\n"
));
chunkqueue_append_string(vr->con->out, html);
chunkqueue_append_string(vr->out, html);
http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
g_string_free(count_req, TRUE);
@ -564,7 +564,7 @@ static handler_t status_page_handle(vrequest *vr, gpointer param, gpointer *cont
VR_DEBUG(vr, "%s", "collecting stats...");
ci = collect_start(vr->con->wrk, status_collect_func, NULL, status_collect_cb, j);
ci = collect_start(vr->wrk, status_collect_func, NULL, status_collect_cb, j);
*context = ci; /* may be NULL */
}

View File

@ -38,7 +38,7 @@ ssize_t net_read(int fd, void *buf, ssize_t nbyte) {
network_status_t network_write(vrequest *vr, int fd, chunkqueue *cq) {
network_status_t res;
ev_tstamp ts, now = CUR_TS(vr->con->wrk);
ev_tstamp ts, now = CUR_TS(vr->wrk);
worker *wrk;
#ifdef TCP_CORK
int corked = 0;
@ -47,7 +47,7 @@ network_status_t network_write(vrequest *vr, int fd, chunkqueue *cq) {
if (CORE_OPTION(CORE_OPTION_THROTTLE).number) {
/* throttling is enabled */
if (G_UNLIKELY((now - vr->con->throttle.ts) > vr->con->wrk->throttle_queue.delay)) {
if (G_UNLIKELY((now - vr->con->throttle.ts) > vr->wrk->throttle_queue.delay)) {
vr->con->throttle.magazine += CORE_OPTION(CORE_OPTION_THROTTLE).number * (now - vr->con->throttle.ts);
if (vr->con->throttle.magazine > CORE_OPTION(CORE_OPTION_THROTTLE).number)
vr->con->throttle.magazine = CORE_OPTION(CORE_OPTION_THROTTLE).number;
@ -85,7 +85,7 @@ network_status_t network_write(vrequest *vr, int fd, chunkqueue *cq) {
#endif
/* stats */
wrk = vr->con->wrk;
wrk = vr->wrk;
wrk->stats.bytes_out += wrote;
vr->con->stats.bytes_out += wrote;
@ -93,21 +93,21 @@ network_status_t network_write(vrequest *vr, int fd, chunkqueue *cq) {
ts = CUR_TS(wrk);
if ((ts - vr->con->stats.last_avg) >= 5.0) {
vr->con->stats.bytes_out_5s_diff = vr->con->wrk->stats.bytes_out - vr->con->wrk->stats.bytes_out_5s;
vr->con->stats.bytes_out_5s_diff = vr->wrk->stats.bytes_out - vr->wrk->stats.bytes_out_5s;
vr->con->stats.bytes_out_5s = vr->con->stats.bytes_out;
vr->con->stats.last_avg = ts;
}
/* only update once a second, the cast is to round the timestamp */
if ((vr->con->io_timeout_elem.ts + 1.) < now)
waitqueue_push(&vr->con->wrk->io_timeout_queue, &vr->con->io_timeout_elem);
waitqueue_push(&vr->wrk->io_timeout_queue, &vr->con->io_timeout_elem);
vr->con->throttle.magazine = write_bytes;
/* check if throttle magazine is empty */
if (CORE_OPTION(CORE_OPTION_THROTTLE).number && write_bytes == 0) {
/* remove EV_WRITE from sockwatcher for now */
ev_io_rem_events(vr->con->wrk->loop, &vr->con->sock_watcher, EV_WRITE);
waitqueue_push(&vr->con->wrk->throttle_queue, &vr->con->throttle.queue_elem);
ev_io_rem_events(vr->wrk->loop, &vr->con->sock_watcher, EV_WRITE);
waitqueue_push(&vr->wrk->throttle_queue, &vr->con->throttle.queue_elem);
return NETWORK_STATUS_WAIT_FOR_AIO_EVENT;
}
@ -119,7 +119,7 @@ network_status_t network_read(vrequest *vr, int fd, chunkqueue *cq) {
off_t max_read = 16 * blocksize; /* 256k */
ssize_t r;
off_t len = 0;
worker *wrk = vr->con->wrk;
worker *wrk = vr->wrk;
ev_tstamp now = CUR_TS(wrk);
if (cq->limit && cq->limit->limit > 0) {
@ -134,7 +134,7 @@ network_status_t network_read(vrequest *vr, int fd, chunkqueue *cq) {
/* only update once a second */
if ((vr->con->io_timeout_elem.ts + 1.) < now)
waitqueue_push(&vr->con->wrk->io_timeout_queue, &vr->con->io_timeout_elem);
waitqueue_push(&vr->wrk->io_timeout_queue, &vr->con->io_timeout_elem);
do {
GByteArray *buf = g_byte_array_sized_new(blocksize);
@ -162,7 +162,7 @@ network_status_t network_read(vrequest *vr, int fd, chunkqueue *cq) {
len += r;
/* stats */
wrk = vr->con->wrk;
wrk = vr->wrk;
wrk->stats.bytes_in += r;
vr->con->stats.bytes_in += r;

View File

@ -338,7 +338,7 @@ void plugins_handle_close(connection *con) {
}
void plugins_handle_vrclose(vrequest *vr) {
GArray *a = vr->con->srv->plugins_handle_vrclose;
GArray *a = vr->wrk->srv->plugins_handle_vrclose;
guint i, len = a->len;
for (i = 0; i < len; i++) {
plugin *p = g_array_index(a, plugin*, i);

View File

@ -253,7 +253,7 @@ handler_t stat_cache_get_dirlist(vrequest *vr, GString *path, stat_cache_entry *
stat_cache_entry *sce;
guint i;
sc = vr->con->wrk->stat_cache;
sc = vr->wrk->stat_cache;
sce = g_hash_table_lookup(sc->dirlists, path);
if (sce) {
@ -292,7 +292,7 @@ handler_t stat_cache_get(vrequest *vr, GString *path, struct stat *st, int *err,
stat_cache_entry *sce;
guint i;
sc = vr->con->wrk->stat_cache;
sc = vr->wrk->stat_cache;
sce = g_hash_table_lookup(sc->entries, path);
if (sce) {

View File

@ -103,6 +103,7 @@ vrequest* vrequest_new(connection *con, vrequest_handler handle_response_headers
vrequest *vr = g_slice_new0(vrequest);
vr->con = con;
vr->wrk = con->wrk;
vr->ref = g_slice_new0(vrequest_ref);
vr->ref->refcount = 1;
vr->ref->vr = vr;
@ -154,11 +155,11 @@ void vrequest_free(vrequest* vr) {
filters_clean(vr, &vr->filters_out);
if (g_atomic_int_get(&vr->queued)) { /* atomic access shouldn't be needed here; no one else can access vr here... */
g_queue_unlink(&vr->con->wrk->job_queue, &vr->job_queue_link);
g_queue_unlink(&vr->wrk->job_queue, &vr->job_queue_link);
g_atomic_int_set(&vr->queued, 0);
}
g_slice_free1(vr->con->srv->option_def_values->len * sizeof(option_value), vr->options);
g_slice_free1(vr->wrk->srv->option_def_values->len * sizeof(option_value), vr->options);
for (i = 0; i < vr->stat_cache_entries->len; i++) {
@ -199,7 +200,7 @@ void vrequest_reset(vrequest *vr) {
filters_reset(vr, &vr->filters_out);
if (g_atomic_int_get(&vr->queued)) { /* atomic access shouldn't be needed here; no one else can access vr here... */
g_queue_unlink(&vr->con->wrk->job_queue, &vr->job_queue_link);
g_queue_unlink(&vr->wrk->job_queue, &vr->job_queue_link);
g_atomic_int_set(&vr->queued, 0);
}
@ -208,7 +209,7 @@ void vrequest_reset(vrequest *vr) {
stat_cache_entry_release(vr, sce);
}
memcpy(vr->options, vr->con->srv->option_def_values->data, vr->con->srv->option_def_values->len * sizeof(option_value));
memcpy(vr->options, vr->wrk->srv->option_def_values->data, vr->wrk->srv->option_def_values->len * sizeof(option_value));
if (1 != g_atomic_int_get(&vr->ref->refcount)) {
/* If we are not the only user of vr->ref we have to get a new one and detach the old */
@ -468,16 +469,16 @@ void vrequest_state_machine(vrequest *vr) {
}
void vrequest_joblist_append(vrequest *vr) {
GQueue *const q = &vr->con->wrk->job_queue;
worker *wrk = vr->con->wrk;
worker *wrk = vr->wrk;
GQueue *const q = &wrk->job_queue;
if (!g_atomic_int_compare_and_exchange(&vr->queued, 0, 1)) return; /* already in queue */
g_queue_push_tail_link(q, &vr->job_queue_link);
ev_timer_start(wrk->loop, &wrk->job_queue_watcher);
}
void vrequest_joblist_append_async(vrequest *vr) {
GAsyncQueue *const q = vr->con->wrk->job_async_queue;
worker *wrk = vr->con->wrk;
worker *wrk = vr->wrk;
GAsyncQueue *const q = wrk->job_async_queue;
if (!g_atomic_int_compare_and_exchange(&vr->queued, 0, 1)) return; /* already in queue */
g_async_queue_push(q, vrequest_acquire_ref(vr));
ev_async_send(wrk->loop, &wrk->job_async_queue_watcher);