List:Cluster« Previous MessageNext Message »
From:George Neill Date:January 23 2012 9:07pm
Subject:ndb_init and ndb_end
View as plain text  
 <cluster@stripped>Hi Folks,

Still in learning mode with the NDB API.   I have a couple more questions I
hope someone can help me out with!

1) It is my understanding that ndb_init() and ndb_end(int) should only be
called ONCE per process, is that correct?

2) I have a question about ndb_end(int) and it's proper usage.

Here's my situation,

I am compiling/testing the ndbrecord api example.  I noticed this
particular example allocates the Ndb_cluster_connection object from the
stack.  In this example, there exists a ndb_init() function call just after
main(),but there's no corresponding ndb_end(int) call before exit.   I have
added a ndb_end(0); right before the return 0; from main().

Now when I run the example, I see this,

fetch_key: Success!
update2_key: Success!
delete_key: Success!
Error in my_thread_global_end(): 5 threads didn't exit

The "Error" line is what my question is about.   There appears to be an
stack unwinding issue as ndb_end(int) gets called before the
Ndb_cluster_connection destructor does.

Is this the way it was intended to work, or is it a bug?

For now I have just wrapped the ndb_init/ndb_end(int) calls in a class and
instantiated it in main() (removing the ndb_init/ndb_end calls in the
example).

class ndbInitialize
{
  public:
  ndbInitialize() { ndb_init(); }
 ~ndbInitialize() { ndb_end(0); }
};

I am interested if anyone else has ran in to this situation and how they
have solved it.

Thanks,
George

Thread
ndb_init and ndb_endGeorge Neill23 Jan
  • Re: ndb_init and ndb_endJonas Oreland24 Jan
    • Re: ndb_init and ndb_endGeorge Neill24 Jan