Bug 970

Summary: Simultaneous resolve/access by multiple clients.
Product: TAO Reporter: Wayne Erchak <werchak>
Component: ORBAssignee: DOC Center Support List (internal) <tao-support>
Status: RESOLVED DUPLICATE    
Severity: normal CC: chughes
Priority: P3    
Version: 1.1.17   
Hardware: x86   
OS: Windows 2000   

Description Wayne Erchak 2001-07-09 13:30:13 CDT
The modified hello client below spawns multiple threads, performing NUM_THREADS 
hello tests at the same time.  When the number of simultaneous accesses is 
greater than the number of default threads on the server, some client threads 
fail to resolve the hello object.  Shouldn't this test succeed regardless of 
the number of threads specified?  


// client.cpp,v 1.2 2001/04/11 02:21:16 coryan Exp

#include "TestC.h"
#include "ace/Get_Opt.h"
#include "ace/Thread_Manager.h"

ACE_RCSID(Hello, client, "client.cpp,v 1.2 2001/04/11 02:21:16 coryan Exp")

namespace {
  const int NUM_THREADS = 20;
}


const char *ior = "file://test.ior";

int
parse_args (int argc, char *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, "k:");
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'k':
	ior = get_opts.optarg;
	break;

      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s "
			   "-k <ior> "
                           "\n",
                           argv [0]),
                          -1);
      }
  // Indicates sucessful parsing of the command line
  return 0;
}

typedef struct {
  CORBA::ORB_ptr orb;
  ACE_Barrier* barrier;
} Parameter;

void* helloTest(void* args) {

  ACE_TRY_NEW_ENV {
    Parameter* parameter = static_cast<Parameter*>(args);

    // Wait for all other threads to reach this point.
    parameter->barrier->wait();
    
    CORBA::Object_var tmp =
      parameter->orb->string_to_object(ior, ACE_TRY_ENV);
    ACE_TRY_CHECK;
    
    Test::Hello_var hello =
      Test::Hello::_narrow(tmp.in (), ACE_TRY_ENV);
    ACE_TRY_CHECK;
    
    if (CORBA::is_nil (hello.in ()))
    {
      ACE_ERROR_RETURN ((LM_DEBUG,
        "Nil Test::Hello reference <%s>\n",
        ior),
        0);
    }
    
    CORBA::String_var the_string =
      hello->get_string (ACE_TRY_ENV);
    ACE_TRY_CHECK;
    
    ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n",
      the_string.in ()));
  }
  
  ACE_CATCHANY
  {
    ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
      "Exception caught:");
    return 0;
  }
  ACE_ENDTRY;

  return 0;
}

int
main (int argc, char *argv[])
{
  ACE_TRY_NEW_ENV
  {
    CORBA::ORB_var orb =
      CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
    ACE_TRY_CHECK;
    
    if (parse_args (argc, argv) != 0)
      return 1;
    
    ACE_Barrier barrier(NUM_THREADS);

    Parameter parameter;
    parameter.orb = orb.in();
    parameter.barrier = &barrier;
    

  ACE_Thread_Manager manager;
  if (manager.spawn_n (NUM_THREADS,
    ACE_THR_FUNC (helloTest),
    &parameter,
    THR_NEW_LWP | THR_JOINABLE) == -1)
    ACE_ERROR ((LM_ERROR,
    ACE_TEXT ("%p\n%a"),
    ACE_TEXT ("thread create failed")));

    // Wait for the threads to exit.
    manager.wait();
    
  }
  ACE_CATCHANY
  {
    ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
      "Exception caught:");
    return 1;
  }
  ACE_ENDTRY;
  
  return 0;
}
Comment 1 Ossama Othman 2001-07-11 15:41:50 CDT
This appears to describe the same problem as in bug 189.  Marking it as a duplicate.



*** This bug has been marked as a duplicate of 189 ***