Beispiel #1
0
        void Vbo::pack() {
            assert(m_state == VboMapped);
            
#ifdef _DEBUG_VBO
            checkBlockChain();
            checkFreeBlocks();
#endif

            if (m_totalCapacity == m_freeCapacity || (m_last->free() && m_last->capacity() == m_freeCapacity)) return;
            
            // find first free block
            VboBlock* block = m_first;
            while (block != NULL && !block->free())
                block = block->m_next;
            while (block != NULL && block->m_next != NULL)
                block = packBlock(*block);

#ifdef _DEBUG_VBO
            checkBlockChain();
            checkFreeBlocks();
#endif
        }
void sendBlock(t_bloque_datos block, struct in_addr ip, int puerto)
{
	int messageLength = tamanio_bloque + sizeof(int) + sizeof(t_header);
	void* message = malloc(messageLength);
	t_header header;

	header.tamanioMensaje = messageLength - sizeof(t_header);
	header.tipoMensaje = EnvioBloque;

	packHeader(header, message);
	packBlock(block, message);

	int sock;

	if((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
	{
			perror("socket");
			exit(1);
	}

	struct sockaddr_in addr;

	addr.sin_addr = ip;
	addr.sin_family = AF_INET;
	addr.sin_port = puerto;
	memset(&(addr.sin_zero), '\0', 8);

	//Conecto al socket al FileSystem para notificar conexion del nodo
	if(connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) == -1)
		{
			perror("connect");
			exit(1);
		}

	sendAll(sock, message, messageLength);


	return;
}