static inline void run_write(struct connection *c) { int i; c->wbuf_pos = c->wbuf; c->iov_used = 0; for (i = 0; i < c->pipelines; i++) { c->writer(c); } c->iov_towrite = sum_iovecs(c->vecs, c->iov_used); write_iovecs(c, c->next_state); if (c->stop_after && *c->write_count >= c->stop_after) { event_del(&c->ev); } }
static void prealloc_write_ascii_decr_to_client(void *arg) { struct connection *c = arg; struct iovec *vecs = c->vecs; vecs[0].iov_base = "decr "; vecs[0].iov_len = 5; vecs[1].iov_base = c->keys[*c->cur_key].key; vecs[1].iov_len = c->keys[*c->cur_key].key_len; vecs[2].iov_base = " 1\r\n"; vecs[2].iov_len = 4; c->iov_towrite = sum_iovecs(vecs, c->iov_count); write_iovecs(c, conn_reading); run_counter(c); }
static void prealloc_write_ascii_mget_to_client(void *arg) { struct connection *c = arg; int i; struct iovec *vecs = c->vecs; vecs[0].iov_base = "get "; vecs[0].iov_len = 4; for (i = 1; i < c->mget_count + 1; i++) { vecs[i].iov_base = c->keys[*c->cur_key].key; vecs[i].iov_len = c->keys[*c->cur_key].key_len; run_counter(c); } vecs[i].iov_base = "\r\n"; vecs[i].iov_len = 2; c->iov_towrite = sum_iovecs(vecs, c->iov_count); write_iovecs(c, conn_reading); }
static void write_ascii_set_to_client(void *arg) { struct connection *c = arg; struct iovec *vecs = c->vecs; vecs[0].iov_base = c->wbuf; vecs[0].iov_len = sprintf(c->wbuf, "set %s%llu 0 0 %d\r\n", c->key_prefix, (unsigned long long)*c->cur_key, c->value_size); if (c->value[0] == '\0') { vecs[1].iov_base = shared_value; } else { vecs[1].iov_base = c->value; } vecs[1].iov_len = c->value_size; vecs[2].iov_base = "\r\n"; vecs[2].iov_len = 2; c->iov_towrite = sum_iovecs(vecs, c->iov_count); write_iovecs(c, conn_reading); run_counter(c); }