Esempio n. 1
0
BOOST_FIXTURE_TEST_CASE(has_correct_payload_length, F)
{
  logsvc::prot::ClientHandle client_handle(42);
  logsvc::prot::Disconnect disconnect(client_handle);
  BOOST_CHECK_EQUAL(client_handle.get_payload_length(),
                    disconnect.get_payload_length());

  logsvc::prot::Disconnect receiving_disconnect;
  BOOST_CHECK_EQUAL(client_handle.get_payload_length(),
                    receiving_disconnect.get_payload_length());
}
Esempio n. 2
0
static void client_connected(struct master_service_connection *conn)
{
	if (to_startup != NULL)
		timeout_remove(&to_startup);
	master_service_client_connection_accept(conn);
	if (ssl_params->used == 0) {
		/* waiting for parameter building to finish */
		if (!array_is_created(&delayed_fds))
			i_array_init(&delayed_fds, 32);
		array_append(&delayed_fds, &conn->fd, 1);
	} else {
		client_handle(conn->fd);
	}
}
Esempio n. 3
0
int server_do(server *s)
{
	fd_set readfds;
	int i;

	/* s->readfds is an accurate list of all our
	 * clients currently connected. Copy it here
	 * and then we can act on every client.
	 */
	readfds = s->readfds;

	select(s->maxfd + 1, &readfds, NULL, NULL, NULL);

	/* Check for file descriptors that need reading
	 * and pass them off to client_handle if they do.
	 */
	for(i = 0; i <= s->maxfd; i++)
	{
		if(!FD_ISSET(i, &readfds))
			continue;

		/* The server's socket needing reading
		 * is special, it means a new client has
		 * connected so handle it seperately.
		 */
		if(i == s->socket)
		{
			int newfd;
			
			newfd = client_init(s->socket);
			if(!newfd)
				continue;
		
			FD_SET(newfd, &s->readfds);
			if(newfd > s->maxfd)
				s->maxfd = newfd;
		} else {
			int r;

			/* If r is 0, then the client disconnected. */
			r = client_handle(i);
			if(!r)
				FD_CLR(i, &s->readfds);
				
		}
	}

	return 1;
}
Esempio n. 4
0
static void ssl_params_callback(const unsigned char *data, size_t size)
{
	const int *fds;

	buffer_set_used_size(ssl_params, 0);
	buffer_append(ssl_params, data, size);

	if (!array_is_created(&delayed_fds)) {
		/* if we don't get client connections soon, it means master
		   ran us at startup to make sure ssl parameters are generated
		   asap. if we're here because of that, don't bother hanging
		   around to see if we get any client connections. */
		to_startup = timeout_add(STARTUP_IDLE_TIMEOUT_MSECS,
					 master_service_stop, master_service);
		return;
	}

	array_foreach(&delayed_fds, fds)
		client_handle(*fds);
	array_free(&delayed_fds);
}
Esempio n. 5
0
File: serve.c Progetto: ivokub/kftp
void * client_handle_middle(void * this_client){
	client_handle((client *) this_client);
	return NULL;
}