Esempio n. 1
0
T_CCI_ERROR_CODE map_get_ots_value (T_CCI_REQ mapped_stmt_id,
                                    T_CCI_REQ *statement_id,
                                    bool force)
{
  T_CCI_ERROR_CODE error;

  if (statement_id == NULL)
    {
      return CCI_ER_REQ_HANDLE;
    }

  mutexStatement.lock ();

  IteratorMapStatement it = mapStatement.find (mapped_stmt_id);
  if (it == mapStatement.end ())
    {
      error = CCI_ER_REQ_HANDLE;
    }
  else
    {
      *statement_id = it->second;
      error = CCI_ER_NO_ERROR;

      if (force == false)
	{
	  T_CON_HANDLE *connection;
	  T_CCI_CONN connection_id = GET_CON_ID (*statement_id);

	  error = hm_get_connection_by_resolved_id (connection_id,
	                                            &connection);
	  if (error == CCI_ER_NO_ERROR)
	    {
	      if (connection->used)
		{
		  error = CCI_ER_USED_CONNECTION;
		}
	      else
		{
		  connection->used = true;
		}
	    }
	}
    }

  mutexStatement.unlock ();

  return error;
}
Esempio n. 2
0
T_CCI_ERROR_CODE map_get_otc_value (T_CCI_CONN mapped_conn_id,
                                    T_CCI_CONN *connection_id,
                                    bool force)
{
  T_CCI_ERROR_CODE error;

  if (connection_id == NULL)
    {
      return CCI_ER_CON_HANDLE;
    }

  mutexConnection.lock ();

  IteratorMapConnection it = mapConnection.find (mapped_conn_id);
  if (it == mapConnection.end ())
    {
      error = CCI_ER_CON_HANDLE;
    }
  else
    {
      *connection_id = it->second;
      error = CCI_ER_NO_ERROR;

      if (force == false)
	{
	  T_CON_HANDLE *connection;

	  error = hm_get_connection_by_resolved_id (*connection_id,
	                                            &connection);
	  if (error == CCI_ER_NO_ERROR)
	    {
	      if (connection->used)
		{
		  error = CCI_ER_USED_CONNECTION;
		}
	      else
		{
		  connection->used = true;
		}
	    }
	}
    }

  mutexConnection.unlock ();

  return error;
}
Esempio n. 3
0
T_CCI_ERROR_CODE map_close_otc (T_CCI_CONN mapped_conn_id)
{
  T_CCI_ERROR_CODE error;
  int i;

  mutexConnection.lock ();

  IteratorMapConnection it = mapConnection.find (mapped_conn_id);
  if (it == mapConnection.end())
    {
      error = CCI_ER_CON_HANDLE;
    }
  else
    {
      T_CON_HANDLE *connection;
      T_REQ_HANDLE **statement_array;

      error = hm_get_connection_by_resolved_id (it->second, &connection);
      if (error == CCI_ER_NO_ERROR && connection != NULL)
	{
	  statement_array = connection->req_handle_table;
	  for (i = 0; statement_array && i < connection->max_req_handle; i++)
	    {
	      if (statement_array[i] != NULL
		  && statement_array[i]->mapped_stmt_id >= 0)
		{
		  map_close_ots (statement_array[i]->mapped_stmt_id);
		  statement_array[i]->mapped_stmt_id = -1;
		}
	    }
	}

      mapConnection.erase(it);
      error = CCI_ER_NO_ERROR;
    }


  mutexConnection.unlock ();

  return error;
}
Esempio n. 4
0
T_CCI_ERROR_CODE map_close_ots (T_CCI_REQ mapped_stmt_id)
{
  T_CCI_ERROR_CODE error;

  mutexStatement.lock ();

  IteratorMapStatement it = mapStatement.find (mapped_stmt_id);
  if (it == mapStatement.end ())
    {
      error = CCI_ER_REQ_HANDLE;
    }
  else
    {
      mapStatement.erase(it);
      error = CCI_ER_NO_ERROR;
    }

  mutexStatement.unlock ();

  return error;
}
Esempio n. 5
0
T_CCI_ERROR_CODE map_open_ots (T_CCI_REQ statement_id,
                               T_CCI_REQ *mapped_stmt_id)
{

  if (mapped_stmt_id == NULL)
    {
      return CCI_ER_REQ_HANDLE;
    }
  else
    {
      *mapped_stmt_id = -1;
    }

  mutexStatement.lock ();

  *mapped_stmt_id = map_get_next_id (mapStatement, currStatement);
  mapStatement[*mapped_stmt_id] = statement_id;

  mutexStatement.unlock ();

  return CCI_ER_NO_ERROR;
}
Esempio n. 6
0
T_CCI_ERROR_CODE map_open_otc (T_CCI_CONN connection_id,
                               T_CCI_CONN *mapped_conn_id)
{
  T_CCI_ERROR_CODE error;

  if (mapped_conn_id == NULL)
    {
      return CCI_ER_CON_HANDLE;
    }
  else
    {
      *mapped_conn_id = -1;
      error = CCI_ER_NO_ERROR;
    }

  mutexConnection.lock ();

  *mapped_conn_id = map_get_next_id (mapConnection, currConnection);
  mapConnection[*mapped_conn_id] = connection_id;

  mutexConnection.unlock ();

  return error;
}