Exemplo n.º 1
0
// Process a batch request.
static void
batch_process_request(batch_transaction* btr)
{
	// Keep the reaper at bay.
	btr->fd_h->last_used = cf_getms();

	cf_buf_builder* bb = 0;
	batch_build_response(btr, &bb);

	int fd = btr->fd_h->fd;

	if (bb) {
		int brv = batch_send_header(fd, bb->used_sz);

		if (brv == 0) {
			brv = batch_send(fd, bb->buf, bb->used_sz, MSG_NOSIGNAL | MSG_MORE);

			if (brv == 0) {
				brv = batch_send_final(fd, 0);
			}
		}
		cf_buf_builder_free(bb);
	}
	else {
		cf_info(AS_BATCH, " batch request: returned no local responses");
		batch_send_final(fd, 0);
	}

	batch_transaction_done(btr);
}
Exemplo n.º 2
0
void *
as_netio_th(void *q_to_wait_on) {
	cf_queue *           q = (cf_queue*)q_to_wait_on;
	while (true) {
		as_netio io;
		if (cf_queue_pop(q, &io, CF_QUEUE_FOREVER) != 0) {
			cf_crash(AS_PROTO, "Failed to pop from IO worker queue.");
		}
		if (io.slow) {
			usleep(g_config.proto_slow_netio_sleep_ms * 1000);
		}
		if (as_netio_send(&io, g_netio_slow_queue, false) != AS_NETIO_CONTINUE) {
			AS_RELEASE_FILE_HANDLE(io.fd_h);
			cf_buf_builder_free(io.bb_r);
		};
	}
}