int JAWS_Pipeline_Accept_Task::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { JAWS_Data_Block *db = dynamic_cast<JAWS_Data_Block *> (mb); JAWS_Pipeline_Handler *task = db->task (); JAWS_Pipeline_Handler *next = dynamic_cast<JAWS_Pipeline_Handler *> (task->next ()); JAWS_IO_Handler *ioh = this->new_handler (db); if (ioh == 0) { ACE_ERROR ((LM_ERROR, "%p\n", "JAWS_Pipeline_Accept_Task::put")); return -1; } ioh->acquire (); ioh->task (next); db->io_handler (ioh); int result = this->handle_put (ioh->message_block (), tv); ioh->release (); return result; }
JAWS_IO_Handler * JAWS_Pipeline_Accept_Task::new_handler (JAWS_Data_Block *data) { // Create a new handler and message block JAWS_Data_Block *ndb = new JAWS_Data_Block (*data); if (ndb == 0) { JAWS_TRACE ("JAWS_Pipeline_Accept_Task::new_handler, failed DB"); return 0; } JAWS_Dispatch_Policy *policy = (this->policy () == 0) ? data->policy () : this->policy (); JAWS_IO_Handler_Factory *ioh_factory = policy->ioh_factory (); JAWS_IO_Handler *nioh = ioh_factory->create_io_handler (); if (nioh == 0) { delete ndb; return 0; } ndb->io_handler (nioh); nioh->task (data->task ()); nioh->message_block (ndb); return nioh; }
int JAWS_Pipeline_Done_Task::put (ACE_Message_Block *mb, ACE_Time_Value *) { JAWS_TRACE ("JAWS_Pipeline_Done_Task::put"); JAWS_Data_Block *data = dynamic_cast<JAWS_Data_Block *> (mb); JAWS_IO_Handler *handler = data->io_handler (); JAWS_Dispatch_Policy *policy = this->policy (); if (policy == 0) policy = data->policy (); // JAWS_IO *io = policy->io (); data->task (0); data->io_handler (0); if (handler) handler->done (); // hack, let Concurrency know we are done. return -2; }
int JAWS_Server::open (JAWS_Pipeline_Handler *protocol, JAWS_Dispatch_Policy *policy) { if (policy == 0) policy = &this->policy_; JAWS_Data_Block *db = new JAWS_Data_Block; if (db == 0) { ACE_DEBUG ((LM_DEBUG, "(%t) JAWS_Server::open, could not create Data_Block\n")); return -1; } // initialize data block db->task (JAWS_Pipeline_Accept_Task_Singleton::instance ()); db->policy (policy); db->io_handler (0); db->task ()->next (protocol); // prime the acceptor if appropriate if (this->dispatch_ == 1) { #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) int n = this->nthreads_; if (this->concurrency_ == 1) n = 1; for (int i = 0; i < n * this->ratio_ - n; i++) db->task ()->put (db); #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ } // The message block should contain an INET_Addr, and call the // io->accept (INET_Addr) method! policy->concurrency ()->put (db); ACE_Thread_Manager::instance ()->wait (); db->release (); return 0; }
int JAWS_Pipeline_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { JAWS_Data_Block *db = dynamic_cast<JAWS_Data_Block *> (mb); JAWS_IO_Handler *ioh = db->io_handler (); // guarantee the handler remains for the duration of this call ioh->acquire (); int status = this->handle_put (db, tv); if (status != -1 && status != 2) { JAWS_Pipeline_Handler *task = ioh->task (); JAWS_Pipeline_Handler *next = dynamic_cast<JAWS_Pipeline_Handler *> (task->next ()); ioh->task (next); } ioh->release (); return status; }