Active Topics

 


Reply
Thread Tools
morusaka's Avatar
Posts: 15 | Thanked: 11 times | Joined on Jan 2010 @ Italy
#1
Hi,

I think I have found an apparently obscure behaviour using RTCom libraries (eventlogger, eventlogger/query, etc).

I'll show you with this little c program:

Code:
#include <stdio.h>
#include <assert.h>
#include <glib-object.h>
#include <rtcom-eventlogger/event.h>
#include <rtcom-eventlogger/eventlogger.h>
#include <rtcom-eventlogger/eventlogger-iter.h>
#include <rtcom-eventlogger/eventlogger-query.h>

void
testme(char skip_query_prepare, char skip_iter)
{
  RTComEl* rtcomel;
  RTComElQuery *query;
  RTComElIter *iter;

  rtcomel = rtcom_el_new();
  assert(rtcomel != NULL);

  query = rtcom_el_query_new(rtcomel);
  assert(query != NULL);

  if (skip_query_prepare != 'y')
  {
    rtcom_el_query_prepare(query, "service", "RTCOM_EL_SERVICE_SMS", RTCOM_EL_OP_EQUAL, NULL);

    if (skip_iter != 'y')
    {
      iter = rtcom_el_get_events(rtcomel, query);
    }
  }

  if (iter) g_object_unref(iter);
  if (query) g_object_unref(query);
  if (rtcomel) g_object_unref(rtcomel);
}

int main()
{
  printf("test without skipping neither rtcom_el_query_prepare nor rtcom_el_get_events\n");
  testme('n','n');

  printf("test skipping rtcom_el_get_events but running rtcom_el_get_events\n");
  testme('n','y');

  printf("test skipping rtcom_el_query_prepare and rtcom_el_get_events\n");
  testme('y','y');

  return 0;
}
As you can see, in testme function I do the following:
  1. get a new RTComEl*
  2. get a new RTComElQuery*
  3. prepare the query for database access
  4. get a new RTComElIter*

Of course if you want to get events from the database you have to get them from the Iter, but this is not the point of my problem.

If you run all the steps above, everything works as expected, but if you only allocate RTComEl and RTComElQuery, trying to free them with g_object_unref results in this assertion:

ERROR:db.c:480:rtcom_el_db_close: assertion failed: (db)
Aborted (core dumped)

Do you know if this is a known bug?
Why I'm supposed to *ALWAYS* get an iter from the query?
I can immagine a situation where I instantiate a new RTComElQuery ptr, than something goes wrong somewhere in my program and I simply want to free resources and exit, without getting any RTComElIter ptr.

Thank you for your help,

Luca.
 

The Following User Says Thank You to morusaka For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 21:14.