Ejemplo n.º 1
0
static void
_work_on_client(struct network_server_s *srv, struct network_client_s *clt)
{
	if ((clt->events & CLT_ERROR) || !clt->events) {
		_client_clean(srv, clt);
		return;
	}

	_client_manage_event(clt, clt->events);

	/* re Monitor the socket */
	if (_client_ready_for_output(clt) && _client_has_pending_output(clt))
		clt->events |= CLT_WRITE;
	if (!(clt->flags & (NETCLIENT_IN_CLOSED|NETCLIENT_IN_PAUSED)))
		clt->events |= CLT_READ;

	if (!clt->events || (clt->events & CLT_ERROR)) {
		_client_clean(srv, clt);
	}
	else {
		g_async_queue_push(srv->queue_monitor, clt);
		ssize_t w = write(srv->wakeup[1], "", 1);
		if (w != 1) {
			GRID_DEBUG("Server: Event thread notification failed");
		}
	}
}
Ejemplo n.º 2
0
static void
_client_react(struct gridd_client_s *client)
{
	EXTRA_ASSERT(client != NULL);
	EXTRA_ASSERT(client->abstract.vtable == &VTABLE_CLIENT);

	if (!client)
		return;
	GError *err = NULL;

	client->tv_step = oio_ext_monotonic_time ();
retry:
	if (!(err = _client_manage_event(client))) {
		if (client->step == REP_READING_SIZE && client->reply
				&& client->reply->len >= 4)
				goto retry;
	}
	else {
		_client_reset_request(client);
		_client_reset_reply(client);
		_client_reset_cnx(client);
		client->error = err;
		client->step = STATUS_FAILED;
	}
}