Exemplo n.º 1
0
std::vector<debug_log> debug_logs(GLuint count)
{
  auto max_message_size = 0;
  glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &max_message_size);

  std::vector<GLenum>  sources      (count);
  std::vector<GLenum>  types        (count);
  std::vector<GLuint>  ids          (count);
  std::vector<GLenum>  severities   (count);
  std::vector<GLsizei> message_sizes(count);
  std::vector<GLchar>  message_data (count * max_message_size);
  auto real_count = glGetDebugMessageLog(count, static_cast<GLsizei>(message_data.size()), &sources[0], &types[0], &ids[0], &severities[0], &message_sizes[0], &message_data[0]);
  sources      .resize(real_count);
  types        .resize(real_count);
  ids          .resize(real_count);
  severities   .resize(real_count);
  message_sizes.resize(real_count);

  std::vector<std::string> messages(real_count);
  auto current_message = message_data.begin();
  for (size_t i = 0; i < message_sizes.size(); ++i)
  {
    messages[i] = std::string(current_message, current_message + message_sizes[i] - 1);
    current_message = current_message + message_sizes[i];
  }

  std::vector<debug_log> debug_logs(real_count);
  for (unsigned i = 0; i < real_count; i++)
    debug_logs[i] = debug_log{sources[i], types[i], ids[i], severities[i], messages[i], nullptr};
  return debug_logs;
}
EAP_FUNC_EXPORT eap_status_e eap_plugin_server_message_if_c::process_message_type_error(
	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
{
	eap_status_e status(eap_status_ok);

	eap_process_tlv_message_data_c message_data(m_am_tools);

	if (message_data.get_is_valid() == false)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
	}

	// Error payload is the first in this case.
	status = message_data.read_parameter_data(parameters, eap_message_payload_index_function, eap_tlv_message_type_error, &m_error_code);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	// Fuction payload is the second in this case.
	status = message_data.read_parameter_data(parameters, eap_message_payload_index_first_parameter, &m_error_function);

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
	return EAP_STATUS_RETURN(m_am_tools, status);
}
eap_status_e eap_plugin_server_message_if_c::get_configuration(
	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
{
	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("%s: eap_plugin_server_message_if_c::get_configuration(): parameters=0x%08x, count=%d\n"),
		 (m_is_client == true) ? "client": "server",
		 parameters,
		 (parameters != 0) ? parameters->get_object_count(): 0));

	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eap_plugin_server_message_if_c::get_configuration()");

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	eap_status_e status(eap_status_ok);

	u32_t parameter_index(eap_message_payload_index_first_parameter);

	eap_process_tlv_message_data_c message_data(m_am_tools);

	if (message_data.get_is_valid() == false)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);

	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);

	if (internal_settings == 0)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
	}

	status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	status = m_am_plugin->get_configuration(
		internal_settings
		);

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
	return EAP_STATUS_RETURN(m_am_tools, status);
}
Exemplo n.º 4
0
int main(void) {
	// read data (this is outside time measurements, since the data comes from anywhere and is assumed in (virtual) memory)
	Mapipbtest__QueryResult query_result;
	create_result_from_csv(&query_result, DATA_FILE, DATA_COLS, DATA_ROWS,
			DATA_TYPES, 1);

	struct snappy_env se;
	snappy_init_env(&se);

	// react on queries
	void *context = zmq_ctx_new();
	void *socket = zmq_socket(context, ZMQ_REP);
	int rc;
	rc = zmq_bind(socket, SERVER_SOCKET);
	if (rc != 0) {
		fprintf(stderr, "Failed to bind to socket %s\n", SERVER_SOCKET);
		perror("Socket error ");
		return -1;
	}

	long s_time, c_time, req_time;
	struct timeval start, req_start;

	while (1) {
		gettimeofday(&req_start, NULL );
		// receive request
		message query_msg;
		message_receive(socket, &query_msg);
		size_t query_msg_size = message_size(&query_msg);
		void * query_msg_data = message_data(&query_msg);
		if (COMPRESS) {
			query_msg_data = message_uncompress(query_msg_data,
					&query_msg_size);
		}
		Mapipbtest__ExecuteQuery * request = mapipbtest__execute_query__unpack(
				NULL, query_msg_size, query_msg_data);
		message_close(&query_msg);
		if (COMPRESS) {
			free(query_msg_data);
		}
		//printf("%s\n", request->sqlquery);
		//mapipbtest__execute_query__free_unpacked(request, NULL );

		// send response
		gettimeofday(&start, NULL );
		size_t query_response_msg_size =
				mapipbtest__query_result__get_packed_size(&query_result);
		void * query_response_msg_data = malloc(query_response_msg_size);
		mapipbtest__query_result__pack(&query_result, query_response_msg_data);

		s_time = end_timer_ms(&start);
		gettimeofday(&start, NULL );
		char * free_ptr;
		if (COMPRESS) {
			free_ptr = query_response_msg_data;
			query_response_msg_data = message_compress(&se,
					query_response_msg_data, &query_response_msg_size);
		}
		c_time = end_timer_ms(&start);

		message_send(socket, query_response_msg_data, query_response_msg_size);
		//free(query_response_msg_data);
		req_time = end_timer_ms(&req_start);

		//free(query_response_msg_data);
		if (COMPRESS) {
			free(free_ptr);
		}

	}
	zmq_close(socket);
	zmq_ctx_destroy(context);
	return 0;
}