Beispiel #1
0
void hammer_sched_add_connection(hammer_connection_t *c, hammer_sched_t *sched, hammer_connection_t *rc)
{
	int ret;

	ret = hammer_epoll_add(sched->epoll_fd, remote_fd, HAMMER_EPOLL_READ,
			HAMMER_EPOLL_LEVEL_TRIGGERED, (void *)c);
	if (hammer_likely(ret == 0)) {
		if (r_conn != NULL) {
			/* r_conn != NULL, this connection is added by connect(), to server */
			c->r_conn = rc;
			rc->r_conn = c;

			sched->connected_connections ++;
		} else {
			/* r_conn == NULL, this connection is added by accept(), from client */
			sched->accepted_connections ++;
		}
	} else {
		/* fails, close the connection */
		hammer_close_connection(c);
		hammer_err("epoll add fails\n");
		exit(0);
	}

	return;
}
Beispiel #2
0
void hammer_sched_add_connection(hammer_connection_t *c, hammer_sched_t *sched)
{
	int ret;

	ret = hammer_epoll_add(sched->epoll_fd, c->socket, HAMMER_EPOLL_READ,
			HAMMER_EPOLL_LEVEL_TRIGGERED, (void *)c);
	if (hammer_likely(ret == 0)) {
		if (c->type == HAMMER_CONN_CLIENT) {
			sched->client_connections ++;
		} else { /* HAMMER_CONN_SERVER */
			sched->server_connections ++;
		}
	} else {
		/* fails, close the connection */
		hammer_close_connection(c);
		hammer_err("epoll add fails\n");
		exit(0);
	}

	return;
}