A bug in CORBA_Object_non_existent

These days we test a App, which using ORBit 0.5.5. We encounter a strange problem.

When a client call CORBA_Object_non_existent and the server is free, but this function
return TRUE. We hacked this function. and find the reason. take a look the following code:

/* Lovely hack to try and figure out without hanging whether an object exists or not. */
CORBA_boolean CORBA_Object_non_existent(CORBA_Object obj, CORBA_Environment *ev)

  childpid = fork();

  if(!childpid) {
          GIOPConnection* cnx = NULL;
          struct sigaction sa;

          memset(&sa, 0, sizeof(sa));
          sa.sa_handler = do_exit;
          sigaction(SIGALRM, &sa, NULL);
          cnx = _ORBit_object_get_connection(obj);

          /* XXX todo - try invoking a strange operation on the object, and see what type of exception we get. */

          _exit((cnx == NULL)?1:0);

  itmp = waitpid(childpid, &exitstatus, 0);

  if(itmp < 0) return TRUE;
  return WEXITSTATUS(exitstatus) && TRUE;

if SIGCHLD signal handler is SIG_IGN and child returned before waitpid, the itmp will be -1,
then this function return TRUE.

So I think add some codes, like that:

  void (*oldsig)(int);

  oldsig = signal(SIGCLD, SIG_DFL);
  childpid = fork();
  itmp = waitpid(childpid, &exitstatus, 0);
  signal(SIGCLD, oldsig);

then waitpid will not return -1;

And former problem didn't appear;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]