Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
}