template <ACE_SYNCH_DECL> int ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *module_name, ACE_Task<ACE_SYNCH_USE> *writer_q, ACE_Task<ACE_SYNCH_USE> *reader_q, void *arg, int flags /* = M_DELETE */) { ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::open"); this->name (module_name); this->arg_ = arg; // We may already have readers and/or writers. if (this->reader ()) this->close_i (0, M_DELETE_READER); if (this->writer ()) this->close_i (1, M_DELETE_WRITER); if (writer_q == 0) { ACE_NEW_RETURN (writer_q, ACE_Thru_Task<ACE_SYNCH_USE>, -1); ACE_SET_BITS (flags, M_DELETE_WRITER); } if (reader_q == 0) { ACE_NEW_RETURN (reader_q, ACE_Thru_Task<ACE_SYNCH_USE>, -1); ACE_SET_BITS (flags, M_DELETE_READER); } this->reader (reader_q); this->writer (writer_q); // Save the flags this->flags_ = flags; // Make sure that the memory is allocated before proceding. if (writer_q == 0 || reader_q == 0) { // These calls will delete writer_q and/or reader_q, if // necessary. this->close_i (0, M_DELETE_READER); this->close_i (1, M_DELETE_WRITER); errno = ENOMEM; return -1; } // Setup back pointers (this must come last, after we've made sure // there's memory allocated here. reader_q->mod_ = this; writer_q->mod_ = this; return 0; }
int ACE_Log_Msg_UNIX_Syslog::convert_log_mask (int lm_mask) { int syslog_mask = 0; if (ACE_BIT_ENABLED (lm_mask, LM_TRACE) || ACE_BIT_ENABLED (lm_mask, LM_DEBUG)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_DEBUG)); if (ACE_BIT_ENABLED (lm_mask, LM_STARTUP) || ACE_BIT_ENABLED (lm_mask, LM_SHUTDOWN) || ACE_BIT_ENABLED (lm_mask, LM_INFO)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_INFO)); if (ACE_BIT_ENABLED (lm_mask, LM_NOTICE)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_NOTICE)); if (ACE_BIT_ENABLED (lm_mask, LM_ERROR)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ERR)); if (ACE_BIT_ENABLED (lm_mask, LM_WARNING)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_WARNING)); if (ACE_BIT_ENABLED (lm_mask, LM_CRITICAL)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_CRIT)); if (ACE_BIT_ENABLED (lm_mask, LM_ALERT)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ALERT)); if (ACE_BIT_ENABLED (lm_mask, LM_EMERGENCY)) ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_EMERG)); return syslog_mask; }
int Priority_Task::open (void *arg) { this->priority_ = *(int *) arg; long flags = THR_NEW_LWP; // To get FIFO scheduling with PTHREADS. ACE_SET_BITS (flags, THR_SCHED_FIFO); // Become an active object. if (this->activate (flags, 1, 0, this->priority_) == -1) { // On Linux, for example, only the superuser can set the policy // to other than ACE_SCHED_OTHER. But with ACE_SCHED_OTHER, // there is only one thread priority value, for example, 0. So, // let the superuser run an interesting test, but for other // users use the minimum ACE_SCHED_OTHER thread priority. long fallback_priority = ACE_Sched_Params::priority_min (ACE_SCHED_OTHER, ACE_SCOPE_THREAD); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) task activation at priority %d with ") ACE_TEXT ("flags 0x%X failed; retry at priority %d with ") ACE_TEXT ("flags 0x%X (errno is %d%p)\n"), this->priority_, flags, fallback_priority, THR_NEW_LWP, ACE_ERRNO_GET, ACE_TEXT (""))); flags = THR_NEW_LWP; this->priority_ = fallback_priority; if (this->activate (flags, 1, 1, this->priority_) == -1) { if (ACE_OS::last_error () == EPERM) ACE_ERROR_RETURN ((LM_INFO, ACE_TEXT ("Insufficient privilege to run this test.\n")), -1); else ACE_DEBUG ((LM_ERROR, ACE_TEXT ("(%t) task activation at priority %d failed, ") ACE_TEXT ("exiting!\n%a"), this->priority_, -1)); } } return 0; }
int ACE_Flag_Manip::set_flags (ACE_HANDLE handle, int flags) { ACE_TRACE ("ACE_Flag_Manip::set_flags"); #if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_LACKS_FCNTL) switch (flags) { case ACE_NONBLOCK: // nonblocking argument (1) // blocking: (0) { u_long nonblock = 1; return ACE_OS::ioctl (handle, FIONBIO, &nonblock); } default: ACE_NOTSUP_RETURN (-1); } #else int val = ACE_OS::fcntl (handle, F_GETFL, 0); if (val == -1) return -1; // Turn on flags. ACE_SET_BITS (val, flags); if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) return -1; else return 0; #endif /* ACE_WIN32 || ACE_LACKS_FCNTL */ }
void ACE_Logging_Strategy::tokenize (ACE_TCHAR *flag_string) { ACE_TCHAR *strtokp; for (ACE_TCHAR *flag = ACE_OS::strtok_r (flag_string, ACE_TEXT ("|"), &strtokp); flag != 0; flag = ACE_OS::strtok_r (0, ACE_TEXT ("|"), &strtokp)) { if (ACE_OS::strcmp (flag, ACE_TEXT ("STDERR")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::STDERR); else if (ACE_OS::strcmp (flag, ACE_TEXT ("LOGGER")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER); else if (ACE_OS::strcmp (flag, ACE_TEXT ("OSTREAM")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE); else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE_LITE")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE_LITE); else if (ACE_OS::strcmp (flag, ACE_TEXT ("SILENT")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::SILENT); else if (ACE_OS::strcmp (flag, ACE_TEXT ("SYSLOG")) == 0) ACE_SET_BITS (this->flags_, ACE_Log_Msg::SYSLOG); } }
int Globals::sched_fifo_init (void) { #if defined (ACE_HAS_THREADS) // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. # if defined (_AIX) || defined (__APPLE__) || defined (BSD) int scope = ACE_SCOPE_THREAD; # else int scope = ACE_SCOPE_PROCESS; # endif /* _AIX */ if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, SCHED_PRIORITY, scope))) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_MAX, "User is not superuser, " "so remain in time-sharing class\n")); ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_NEW_LWP); GLOBALS::instance ()->default_priority = ACE_THR_PRI_OTHER_DEF; return 1; } else ACE_ERROR_RETURN ((LM_ERROR, "%n: ACE_OS::sched_params failed\n%a"), -1); } ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_BOUND); ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_SCHED_FIFO); GLOBALS::instance ()->default_priority = ACE_THR_PRI_FIFO_DEF; return 0; #else ACE_ERROR_RETURN ((LM_ERROR, "Test will not run. This platform doesn't seem to have threads.\n"), -1); #endif /* ACE_HAS_THREADS */ }
template <ACE_SYNCH_DECL> void ACE_Module<ACE_SYNCH_USE>::reader (ACE_Task<ACE_SYNCH_USE> *q, int flags /* = M_DELETE_READER */) { ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::reader"); // Close and maybe delete old writer this->close_i (0, flags); this->q_pair_[0] = q; if (q != 0) { ACE_SET_BITS (q->flags_, ACE_Task_Flags::ACE_READER); // Set the q's module pointer to point to us. q->mod_ = this; } // don't allow the caller to change the reader status ACE_SET_BITS (flags_, (flags & M_DELETE_READER)); }
int Sender::initiate_io (ACE_Reactor_Mask mask) { if (ACE_BIT_ENABLED (flg_mask_, mask)) return 0; if (ACE_Reactor::instance ()->schedule_wakeup (this, mask) == -1) return -1; ACE_SET_BITS (flg_mask_, mask); return 0; }
int ACE_FoxReactor::remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_FoxReactor::remove_handler_i"); // In the registration phase we registered first with // ACE_Select_Reactor and then with X. Now we are now doing things // in reverse order. int condition = 0; if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, FX::INPUT_READ); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, FX::INPUT_WRITE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, FX::INPUT_EXCEPT); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, FX::INPUT_READ); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) { ACE_SET_BITS (condition, FX::INPUT_WRITE); // connected, you may write ACE_SET_BITS (condition, FX::INPUT_READ); // connected, you have data/err } // First clean up the corresponding X11Input. fxapp->removeInput ((int)handle,condition); // ACE_reinterpret_cast(int,handle)); // Now let the reactor do its work. return ACE_Select_Reactor::remove_handler_i (handle, mask); }
int ACE_FoxReactor::register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_FoxReactor::register_handler_i"); int const result = ACE_Select_Reactor::register_handler_i (handle, handler, mask); if (result == -1) return -1; unsigned long condition = 0; if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, FX::INPUT_READ); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, FX::INPUT_WRITE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, FX::INPUT_EXCEPT); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, FX::INPUT_READ); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) { ACE_SET_BITS (condition, FX::INPUT_WRITE); // connected, you may write ACE_SET_BITS (condition, FX::INPUT_READ); // connected, you have data/err } if (condition != 0) { fxapp->addInput(handle, condition, this, 0); } return 0; }
int ACE_XtReactor::compute_Xt_condition(ACE_HANDLE handle) { ACE_TRACE ("ACE_XtReactor::compute_Xt_condition"); // Retrieve current wait mask from base class. // The returned value is either a combination of READ/WRITE/EXCEPT_MASK // or -1. int mask =this->bit_ops(handle, 0, this->wait_set_, ACE_Reactor::GET_MASK); if (mask == -1) // No active mask. return 0; int condition = 0; #if !defined ACE_WIN32 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, XtInputExceptMask); #else if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteWinsock); // EXCEPT_MASK is not supported for WIN32. As this was // already handled in register_handler_i, no check here. #endif /* !ACE_WIN32 */ return condition; }
void ACE_Synch_Options::set (unsigned long options, const ACE_Time_Value &timeout, const void *arg) { // ACE_TRACE ("ACE_Synch_Options::set"); this->options_ = options; this->timeout_ = timeout; // Whoa, possible dependence on static initialization here. This // function is called during initialization of the statics above. // But, ACE_Time_Value::zero is a static object. Very fortunately, // its bits have a value of 0. if (this->timeout_ != ACE_Time_Value::zero) ACE_SET_BITS (this->options_, ACE_Synch_Options::USE_TIMEOUT); this->arg_ = arg; }
template <ACE_SYNCH_DECL> int ACE_Module<ACE_SYNCH_USE>::close (int flags /* = M_DELETE_NONE */) { ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::close"); int result = 0; // Only pay attention to the flags parameter if we haven't already // set the task delete policies. if (this->flags_ == M_FLAGS_NOT_SET) ACE_SET_BITS (flags_, flags); if (this->close_i (0, flags_) == -1) result = -1; if (this->close_i (1, flags_) == -1) result = -1; return result; }
int KSG_Service_Handler::open() { this->request_time_ = ACE_OS::gettimeofday(); this->connect_time_ = this->request_time_; char val[2] = ""; int len = 1; val[0] = 0x1; if(ACE_OS::setsockopt(peer().get_handle(),SOL_SOCKET,TCP_NODELAY,val,len)!=0) ACE_DEBUG((LM_ERROR,"创建新连接,设置属性失败")); // 准备读取数据 if(this->reactor()->register_handler(this,ACE_Event_Handler::READ_MASK)) { ACE_DEBUG((LM_ERROR,"注册侦听句柄失败")); return -1; } ACE_Time_Value reschedule (max_client_timeout_.sec () / 4); reactor()->schedule_timer(this,0,max_client_timeout_,reschedule); ACE_SET_BITS(this->mask_,ACE_Event_Handler::READ_MASK); return 0; }
template <ACE_SYNCH_DECL, class TIME_POLICY> void ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q, int flags /* = M_DELETE_WRITER */) { ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer"); // Close and maybe delete old writer this->close_i (1, flags); this->q_pair_[1] = q; if (q != 0) { ACE_CLR_BITS (q->flags_, ACE_Task_Flags::ACE_READER); // Set the q's module pointer to point to us. q->mod_ = this; } // Don't allow the caller to change the reader status. ACE_SET_BITS (flags_, (flags & M_DELETE_WRITER)); }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Flags are file status flags to turn on. int ACE::set_flags (ACE_HANDLE handle, int flags) { ACE_TRACE ("ACE::set_flags"); #if defined (ACE_LACKS_FCNTL) switch (flags) { case ACE_NONBLOCK: // nonblocking argument (1) // blocking: (0) { int nonblock = 1; return ACE_OS::ioctl (handle, FIONBIO, &nonblock); } default: ACE_NOTSUP_RETURN (-1); } #else int val = ACE_OS::fcntl (handle, F_GETFL, 0); if (val == -1) return -1; // Turn on flags. ACE_SET_BITS (val, flags); if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) return -1; else return 0; #endif /* ACE_LACKS_FCNTL */ }
int main (int argc, char *argv[]) { // Note that the default behavior is to log to STDERR... int counter = 1 ; if (argc > 1) { if (ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::OSTREAM) == -1) ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); cause_error (); // Check to see what happened. if (ACE_LOG_MSG->op_status () == -1 && ACE_LOG_MSG->errnum () == EWOULDBLOCK) ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); else ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); } else { if (ACE_LOG_MSG->open (argv[0]) == -1) ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); cause_error (); // Check to see what happened. if (ACE_LOG_MSG->op_status () == -1 && ACE_LOG_MSG->errnum () == EWOULDBLOCK) ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); else ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); // Exercise many different combinations of STDERR and OSTREAM. ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", 3.1416 * counter++, 8, "", "hello", 10000)); ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cout); ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->msg_ostream (0); ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cerr); ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", 3.1416 * counter, 8, "", "world", 10000 * counter++)); static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}; // Print out the binary bytes of the array in hex form. ACE_LOG_MSG->log_hexdump (LM_DEBUG, (char *) array, sizeof array); // Disable the LM_DEBUG and LM_INFO messages at the process level. u_long priority_mask = ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS); ACE_CLR_BITS (priority_mask, LM_DEBUG | LM_INFO); ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); ACE_SET_BITS (priority_mask, LM_INFO); ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); ACE_DEBUG ((LM_INFO, "This LM_INFO message should print!\n")); ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); ACE_CLR_BITS (priority_mask, LM_INFO); ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); char badname[] = "badname"; char *l_argv[2]; l_argv[0] = badname; l_argv[1] = 0; if (ACE_OS::execv (badname, l_argv) == -1) { ACE_ERROR ((LM_ERROR, "%n: (%x), %p%r\n", 10000, badname, cleanup)); ACE_OS::_exit (); } } return 0; }
int MCT_Config::open (int argc, ACE_TCHAR *argv[]) { int retval = 0; int help = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_Get_Opt getopt (argc, argv, ACE_TEXT (":?"), 1, 1); //FUZZ: enable check_for_lack_ACE_OS if (getopt.long_option (ACE_TEXT ("GroupStart"), 'g', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add GroupStart option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Groups"), 'n', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Groups option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Debug"), 'd', ACE_Get_Opt::NO_ARG) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Debug option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Role"), 'r', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Role option.\n")), 1); if (getopt.long_option (ACE_TEXT ("SDM_options"), 'm', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Multicast_Options option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Iterations"), 'i', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add iterations option.\n")), 1); if (getopt.long_option (ACE_TEXT ("TTL"), 't', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add TTL option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Wait"), 'w', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add wait option.\n")), 1); if (getopt.long_option (ACE_TEXT ("help"), 'h', ACE_Get_Opt::NO_ARG) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add help option.\n")), 1); //FUZZ: disable check_for_lack_ACE_OS // Now, let's parse it... int c = 0; while ((c = getopt ()) != EOF) { //FUZZ: enable check_for_lack_ACE_OS switch (c) { case 0: // Long Option. This should never happen. retval = -1; break; case 'g': { // @todo validate all these, i.e., must be within range // 224.255.0.0 to 238.255.255.255, but we only allow the // administrative "site local" range, 239.255.0.0 to // 239.255.255.255. ACE_TCHAR *group = getopt.opt_arg (); if (this->group_start_.set (group) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Bad group address:%s\n"), group)); } } break; case 'i': this->iterations_ = ACE_OS::atoi (getopt.opt_arg ()); break; case 'n': { int n = ACE_OS::atoi (getopt.opt_arg ()); // I'm assuming 0 means unlimited, so just use whatever the // user provides. Seems to work okay on Solaris 5.8. if (IP_MAX_MEMBERSHIPS == 0) this->groups_ = n; else this->groups_ = ACE_MIN (ACE_MAX (n, MCT_MIN_GROUPS), IP_MAX_MEMBERSHIPS); break; } case 'd': this->debug_ = 1; break; case 'r': { ACE_TCHAR *c = getopt.opt_arg (); if (ACE_OS::strcasecmp (c, ACE_TEXT ("CONSUMER")) == 0) this->role_ = CONSUMER; else if (ACE_OS::strcasecmp (c, ACE_TEXT ("PRODUCER")) == 0) this->role_ = PRODUCER; else { help = 1; retval = -1; } } break; case 'm': { //@todo add back OPT_BINDADDR_NO... ACE_TCHAR *c = getopt.opt_arg (); if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_YES")) == 0) ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_NO")) == 0) ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_BINDADDR")) == 0) { ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::DEFOPT_BINDADDR); } else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ALL")) == 0) ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ONE")) == 0) ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_NULLIFACE")) == 0) { ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE); } else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPTS")) == 0) this->sdm_opts_ = ACE_SOCK_Dgram_Mcast::DEFOPTS; else { help = 1; retval = -1; } } break; case 't': this->ttl_ = ACE_OS::atoi (getopt.opt_arg ()); break; case 'w': this->wait_ = ACE_OS::atoi (getopt.opt_arg ()); break; case ':': // This means an option requiring an argument didn't have one. ACE_ERROR ((LM_ERROR, ACE_TEXT (" Option '%c' requires an argument but ") ACE_TEXT ("none was supplied\n"), getopt.opt_opt ())); help = 1; retval = -1; break; case '?': case 'h': default: if (ACE_OS::strcmp (argv[getopt.opt_ind () - 1], ACE_TEXT ("-?")) != 0 && getopt.opt_opt () != 'h') // Don't allow unknown options. ACE_ERROR ((LM_ERROR, ACE_TEXT (" Found an unknown option (%c) ") ACE_TEXT ("we couldn't handle.\n"), getopt.opt_opt ())); // getopt.last_option ())); //readd with "%s" when // last_option() is available. help = 1; retval = -1; break; } } if (retval == -1) { if (help) // print usage here ACE_ERROR ((LM_ERROR, ACE_TEXT ("usage: %s [options]\n") ACE_TEXT ("Options:\n") ACE_TEXT (" -g {STRING} --GroupStart={STRING} ") ACE_TEXT ("starting multicast group address\n") ACE_TEXT (" ") ACE_TEXT ("(default=239.255.0.1:16000)\n") ACE_TEXT (" -n {#} --Groups={#} ") ACE_TEXT ("number of groups (default=5)\n") ACE_TEXT (" -d --Debug ") ACE_TEXT ("debug flag (default=off)\n") ACE_TEXT (" -r {STRING} --Role={STRING} ") ACE_TEXT ("role {PRODUCER|CONSUMER|BOTH}\n") ACE_TEXT (" ") ACE_TEXT ("(default=BOTH)\n") ACE_TEXT (" -m {STRING} --SDM_options={STRING} ") ACE_TEXT ("ACE_SOCK_Dgram_Mcast ctor options\n") ACE_TEXT (" ") ACE_TEXT ("(default=DEFOPTS)\n") ACE_TEXT (" -i {#} --Iterations={#} ") ACE_TEXT ("number of iterations (default=100)\n") ACE_TEXT (" -t {#} --TTL={#} ") ACE_TEXT ("time to live (default=1)\n") ACE_TEXT (" -w {#} --Wait={#} ") ACE_TEXT ("number of seconds to wait on CONSUMER\n") ACE_TEXT (" ") ACE_TEXT ("(default=2)\n") ACE_TEXT (" -h/? --help ") ACE_TEXT ("show this message\n"), argv[0])); return -1; } return 0; }
int ACE_TkReactor::register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_TkReactor::register_handler_i"); int result = ACE_Select_Reactor::register_handler_i (handle, handler, mask); if (result == -1) return -1; int condition = 0; #if !defined ACE_WIN32 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, TK_READABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, TK_WRITABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, TK_EXCEPTION); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, TK_READABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, TK_READABLE); // connected, you may write ACE_SET_BITS (condition, TK_WRITABLE); // connected, you have data/err } #else if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, TK_READABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, TK_WRITABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_NOTSUP_RETURN(-1); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, TK_READABLE); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, TK_READABLE); // connected, you may write ACE_SET_BITS (condition, TK_WRITABLE); // connected, you have data/err } #endif /* !ACE_WIN32 */ if (condition != 0) { ACE_TkReactorID *TkID = this->ids_; while(TkID) { if (TkID->handle_ == handle) { ::Tk_DeleteFileHandler (TkID->handle_); ACE_TkReactor_Input_Callback *callback; ACE_NEW_RETURN (callback, ACE_TkReactor_Input_Callback, -1); callback->reactor_ = this; callback->handle_ = handle; ::Tk_CreateFileHandler ((int) handle, condition, InputCallbackProc, (ClientData) callback); return 0; } else TkID = TkID->next_; } ACE_NEW_RETURN (TkID, ACE_TkReactorID, -1); TkID->next_ = this->ids_; TkID->handle_ = handle; ACE_TkReactor_Input_Callback *callback; ACE_NEW_RETURN (callback, ACE_TkReactor_Input_Callback, -1); callback->reactor_ = this; callback->handle_ = handle; ::Tk_CreateFileHandler ((int) handle, condition, InputCallbackProc, (ClientData) callback); this->ids_ = TkID; } return 0; }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Parse the string containing (thread) priorities and set them // accordingly. void ACE_Logging_Strategy::priorities (ACE_TCHAR *priority_string, ACE_Log_Msg::MASK_TYPE mask) { u_long priority_mask = 0; // Choose priority mask to change. if (mask == ACE_Log_Msg::PROCESS) priority_mask = process_priority_mask_; else priority_mask = thread_priority_mask_; ACE_TCHAR *strtokp = 0; // Parse string and alternate priority mask. for (ACE_TCHAR *priority = ACE_OS::strtok_r (priority_string, ACE_TEXT ("|"), &strtokp); priority != 0; priority = ACE_OS::strtok_r (0, ACE_TEXT ("|"), &strtokp)) { if (ACE_OS::strcmp (priority, ACE_TEXT ("SHUTDOWN")) == 0) ACE_SET_BITS (priority_mask, LM_SHUTDOWN); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~SHUTDOWN")) == 0) ACE_CLR_BITS (priority_mask, LM_SHUTDOWN); else if (ACE_OS::strcmp (priority, ACE_TEXT ("TRACE")) == 0) ACE_SET_BITS (priority_mask, LM_TRACE); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~TRACE")) == 0) ACE_CLR_BITS (priority_mask, LM_TRACE); else if (ACE_OS::strcmp (priority, ACE_TEXT ("DEBUG")) == 0) ACE_SET_BITS (priority_mask, LM_DEBUG); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~DEBUG")) == 0) ACE_CLR_BITS (priority_mask, LM_DEBUG); else if (ACE_OS::strcmp (priority, ACE_TEXT ("INFO")) == 0) ACE_SET_BITS (priority_mask, LM_INFO); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~INFO")) == 0) ACE_CLR_BITS (priority_mask, LM_INFO); else if (ACE_OS::strcmp (priority, ACE_TEXT ("NOTICE")) == 0) ACE_SET_BITS (priority_mask, LM_NOTICE); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~NOTICE")) == 0) ACE_CLR_BITS (priority_mask, LM_NOTICE); else if (ACE_OS::strcmp (priority, ACE_TEXT ("WARNING")) == 0) ACE_SET_BITS (priority_mask, LM_WARNING); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~WARNING")) == 0) ACE_CLR_BITS (priority_mask, LM_WARNING); else if (ACE_OS::strcmp (priority, ACE_TEXT ("STARTUP")) == 0) ACE_SET_BITS (priority_mask, LM_STARTUP); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~STARTUP")) == 0) ACE_CLR_BITS (priority_mask, LM_STARTUP); else if (ACE_OS::strcmp (priority, ACE_TEXT ("ERROR")) == 0) ACE_SET_BITS (priority_mask, LM_ERROR); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~ERROR")) == 0) ACE_CLR_BITS (priority_mask, LM_ERROR); else if (ACE_OS::strcmp (priority, ACE_TEXT ("CRITICAL")) == 0) ACE_SET_BITS (priority_mask, LM_CRITICAL); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~CRITICAL")) == 0) ACE_CLR_BITS (priority_mask, LM_CRITICAL); else if (ACE_OS::strcmp (priority, ACE_TEXT ("ALERT")) == 0) ACE_SET_BITS (priority_mask, LM_ALERT); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~ALERT")) == 0) ACE_CLR_BITS (priority_mask, LM_ALERT); else if (ACE_OS::strcmp (priority, ACE_TEXT ("EMERGENCY")) == 0) ACE_SET_BITS (priority_mask, LM_EMERGENCY); else if (ACE_OS::strcmp (priority, ACE_TEXT ("~EMERGENCY")) == 0) ACE_CLR_BITS (priority_mask, LM_EMERGENCY); } // Affect right priority mask. if (mask == ACE_Log_Msg::PROCESS) process_priority_mask_ = priority_mask; else thread_priority_mask_ = priority_mask; }
int ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Logging_Strategy::parse_args"); ACE_TCHAR *temp; // Perform data member initializations. BTW, do *not* initialize // <thread_priority_mask_> or <process_priority_mask_> here to avoid // unduing the behavior in <init>, where these are set by // <ACE_Log_Msg::instance>. this->flags_ = 0; this->wipeout_logfile_ = false; this->count_ = 0; this->fixed_number_ = false; this->order_files_ = false; this->max_file_number_ = 1; this->interval_ = ACE_DEFAULT_LOGFILE_POLL_INTERVAL; this->max_size_ = 0; ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("f:i:k:m:n:N:op:s:t:w"), 0); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'f': temp = get_opt.opt_arg (); // Now tokenize the string to get all the flags this->tokenize (temp); // If LOGGER was specified, set up the default logger key. // The key can be changed by the -k option also, so if it's // been set already, don't set it. if (ACE_BIT_ENABLED (this->flags_, ACE_Log_Msg::LOGGER) && this->logger_key_ == 0) this->logger_key_ = ACE::strnew (ACE_DEFAULT_LOGGER_KEY); break; case 'i': // Interval (in secs) at which logfile size is sampled. this->interval_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10); break; case 'k': // Ensure that the LOGGER flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER); delete [] this->logger_key_; this->logger_key_ = ACE::strnew (get_opt.opt_arg ()); break; case 'm': // Maximum logfile size (in KB). Must be a non-zero value. this->max_size_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10); this->max_size_ <<= 10; // convert from KB to bytes. break; case 'n': delete [] this->program_name_; this->program_name_ = ACE::strnew (get_opt.opt_arg ()); break; case 'N': // The max number for the log_file being created this->max_file_number_ = ACE_OS::atoi (get_opt.opt_arg ()) - 1; this->fixed_number_ = true; break; case 'o': // Log_files generation order this->order_files_ = true; break; case 'p': temp = get_opt.opt_arg (); // Now tokenize the string to setup process log priority this->priorities (temp, ACE_Log_Msg::PROCESS); break; case 's': // Ensure that the OSTREAM flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); delete [] this->filename_; this->filename_ = ACE::strnew (get_opt.opt_arg ()); break; case 't': temp = get_opt.opt_arg (); // Now tokenize the string to setup thread log priority this->priorities (temp, ACE_Log_Msg::THREAD); break; case 'w': // Cause the logfile to be wiped out, both on startup and on // reconfigure. this->wipeout_logfile_ = true; break; default: break; } } return 0; }
int ACE_Service_Gestalt::open_i (const ACE_TCHAR program_name[], const ACE_TCHAR* logger_key, bool ignore_static_svcs, bool ignore_default_svc_conf_file, bool ignore_debug_flag) { ACE_TRACE ("ACE_Service_Gestalt::open_i"); int result = 0; ACE_Log_Msg *log_msg = ACE_LOG_MSG; this->no_static_svcs_ = ignore_static_svcs; // Record the current log setting upon entering this thread. u_long old_process_mask = log_msg->priority_mask (ACE_Log_Msg::PROCESS); u_long old_thread_mask = log_msg->priority_mask (ACE_Log_Msg::THREAD); #ifndef ACE_NLOGGING if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ") ACE_TEXT ("opened=%d, loadstatics=%d\n"), this, this->is_opened_, this->no_static_svcs_)); #endif // Guard against reentrant processing. For example, // if the singleton gestalt (ubergestalt) was already open, // do not open it again... if (this->is_opened_++ != 0) return 0; if (this->init_i () != 0) return -1; u_long flags = log_msg->flags (); // Only use STDERR if the caller hasn't already set the flags. if (flags == 0) flags = (u_long) ACE_Log_Msg::STDERR; const ACE_TCHAR *key = logger_key; if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) { // Only use the static <logger_key_> if the caller doesn't // override it in the parameter list or if the key supplied is // equal to the default static logger key. key = this->logger_key_; } else { ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); } if (log_msg->open (program_name, flags, key) == -1) return -1; if (!ignore_debug_flag) { // If -d was included as a startup parameter, the user wants debug // information printed during service initialization. if (ACE::debug ()) ACE_Log_Msg::enable_debug_messages (); else // The user has requested no debugging info. ACE_Log_Msg::disable_debug_messages (); } // See if we need to load the static services. if (this->no_static_svcs_ == 0 && this->load_static_svcs () == -1) result = -1; else { if (this->process_directives (ignore_default_svc_conf_file) == -1) result = -1; else result = this->process_commandline_directives (); } // Reset debugging back to the way it was when we came into // into <open_i>. { // Make sure to save/restore errno properly. ACE_Errno_Guard error (errno); if (!ignore_debug_flag) { log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS); log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD); } } return result; } /* open_i () */
int ACE_XtReactor::register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_XtReactor::register_handler_i"); // Make sure we have a valid context ACE_ASSERT (this->context_ != 0); int result = ACE_Select_Reactor::register_handler_i (handle, handler, mask); if (result == -1) return -1; int condition = 0; #if !defined ACE_WIN32 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_SET_BITS (condition, XtInputExceptMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, XtInputReadMask); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, XtInputWriteMask); // connected, you may write ACE_SET_BITS (condition, XtInputReadMask); // connected, you have data/err } #else if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) ACE_SET_BITS (condition, XtInputReadWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) ACE_SET_BITS (condition, XtInputWriteWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) ACE_NOTSUP_RETURN(-1); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) ACE_SET_BITS (condition, XtInputReadWinsock); if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ ACE_SET_BITS (condition, XtInputWriteWinsock); // connected, you may write ACE_SET_BITS (condition, XtInputReadWinsock); // connected, you have data/err } #endif /* !ACE_WIN32 */ if (condition != 0) { ACE_XtReactorID *XtID = this->ids_; while(XtID) { if (XtID->handle_ == handle) { ::XtRemoveInput (XtID->id_); XtID->id_ = ::XtAppAddInput (this->context_, (int) handle, (XtPointer) condition, InputCallbackProc, (XtPointer) this); return 0; } else XtID = XtID->next_; } ACE_NEW_RETURN (XtID, ACE_XtReactorID, -1); XtID->next_ = this->ids_; XtID->handle_ = handle; XtID->id_ = ::XtAppAddInput (this->context_, (int) handle, (XtPointer) condition, InputCallbackProc, (XtPointer) this); this->ids_ = XtID; } return 0; }
int ACE_Service_Config::open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key, bool , bool , bool ) { ACE_TRACE ("ACE_Service_Config::open_i"); ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); ACE_Log_Msg *log_msg = ACE_LOG_MSG; if(ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"), this, this->is_opened_)); // Guard against reentrant processing. if(this->is_opened_) return 0; this->is_opened_ = true; // Check for things we need to do on a per-process basis and which // may not be safe, or wise to do an a per instance basis // Become a daemon before doing anything else. if(ACE_Service_Config::be_a_daemon_) ACE::daemonize (); // Write process id to file. if(this->pid_file_name_ != 0) { FILE* pidf = ACE_OS::fopen (this->pid_file_name_, ACE_TEXT("w")); if(pidf != 0) { ACE_OS::fprintf (pidf, "%ld\n", static_cast<long> (ACE_OS::getpid())); ACE_OS::fclose (pidf); } } u_long flags = log_msg->flags (); // Only use STDERR if the caller hasn't already set the flags. if(flags == 0) flags = (u_long) ACE_Log_Msg::STDERR; const ACE_TCHAR *key = logger_key; if(key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) { // Only use the static <logger_key_> if the caller doesn't // override it in the parameter list or if the key supplied is // equal to the default static logger key. key = ACE_Service_Config::current()->logger_key_; } else { ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); } if(log_msg->open (program_name, flags, key) == -1) return -1; if(ACE::debug ()) ACE_DEBUG ((LM_STARTUP, ACE_TEXT ("starting up daemon %n\n"))); // Initialize the Service Repository (this will still work if // user forgets to define an object of type ACE_Service_Config). ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES); // Initialize the ACE_Reactor (the ACE_Reactor should be the // same size as the ACE_Service_Repository). ACE_Reactor::instance (); // There's no point in dealing with this on NT since it doesn't // really support signals very well... #if !defined (ACE_LACKS_UNIX_SIGNALS) // Only attempt to register a signal handler for positive // signal numbers. if(ACE_Service_Config::signum_ > 0) { ACE_Sig_Set ss; ss.sig_add (ACE_Service_Config::signum_); if((ACE_Reactor::instance () != 0) && (ACE_Reactor::instance ()->register_handler (ss, ACE_Service_Config::signal_handler_) == -1)) ACE_ERROR ((LM_ERROR, ACE_TEXT ("can't register signal handler\n"))); } #endif /* ACE_LACKS_UNIX_SIGNALS */ return 0; }
ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool ( const ACE_TCHAR *backing_store_name, const OPTIONS *options) : base_addr_ (0), use_fixed_addr_(0), flags_ (MAP_SHARED), write_each_page_ (false), minimum_bytes_ (0), sa_ (0), file_mode_ (ACE_DEFAULT_FILE_PERMS), install_signal_handler_ (true) { ACE_TRACE ("ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool"); #if (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) // For plaforms that give the faulting address. guess_on_fault_ = false; #else // For plaforms that do NOT give the faulting address, let the // options decide whether to guess or not. if (options) guess_on_fault_ = options->guess_on_fault_; else // If no options are specified, default to true. guess_on_fault_ = true; #endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */ // Only change the defaults if <options> != 0. if (options) { if (options->flags_ != 0) this->flags_ = options->flags_; use_fixed_addr_ = options->use_fixed_addr_; if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED) { this->base_addr_ = const_cast<void *> (options->base_addr_); ACE_SET_BITS (flags_, MAP_FIXED); } this->write_each_page_ = options->write_each_page_; this->minimum_bytes_ = options->minimum_bytes_; if (options->sa_ != 0) this->sa_ = options->sa_; this->file_mode_ = options->file_mode_; this->install_signal_handler_ = options->install_signal_handler_; } if (backing_store_name == 0) { // Only create a new unique filename for the backing store file // if the user didn't supply one... #if defined (ACE_DEFAULT_BACKING_STORE) // Create a temporary file. ACE_OS::strcpy (this->backing_store_name_, ACE_DEFAULT_BACKING_STORE); #else /* ACE_DEFAULT_BACKING_STORE */ if (ACE::get_temp_dir (this->backing_store_name_, MAXPATHLEN - 17) == -1) // -17 for ace-malloc-XXXXXX { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->backing_store_name_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->backing_store_name_, ACE_TEXT ("ace-malloc-XXXXXX")); // If requested an unique filename, use mktemp to get a random file. if (options && options->unique_) # if defined (ACE_DISABLE_MKTEMP) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("mktemp disabled; ") ACE_TEXT ("can't generate unique name"))); this->backing_store_name_[0] = 0; } # else ACE_OS::mktemp(this->backing_store_name_); # endif /* ACE_DISABLE_MKTEMP */ #endif /* ACE_DEFAULT_BACKING_STORE */ } else ACE_OS::strsncpy (this->backing_store_name_, backing_store_name, (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR))); #if !defined (ACE_WIN32) if (this->install_signal_handler_) { if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p\n"), this->backing_store_name_)); } #endif /* ACE_WIN32 */ }
// Perform GET, CLR, SET, and ADD operations on the Handle_Sets. // // GET = 1, Retrieve current value // SET = 2, Set value of bits to new mask (changes the entire mask) // ADD = 3, Bitwise "or" the value into the mask (only changes // enabled bits) // CLR = 4 Bitwise "and" the negation of the value out of the mask // (only changes enabled bits) // // Returns the original mask. Must be called with locks held. int ACE_Select_Reactor_Impl::bit_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Select_Reactor_Handle_Set &handle_set, int ops) { ACE_TRACE ("ACE_Select_Reactor_Impl::bit_ops"); if (this->handler_rep_.handle_in_range (handle) == 0) return -1; #if !defined (ACE_WIN32) ACE_Sig_Guard sb (0, this->mask_signals_); // Block out all signals until method returns. #endif /* ACE_WIN32 */ ACE_FDS_PTMF ptmf = &ACE_Handle_Set::set_bit; u_long omask = ACE_Event_Handler::NULL_MASK; // Find the old reactor masks. This automatically does the work of // the GET_MASK operation. if (handle_set.rd_mask_.is_set (handle)) ACE_SET_BITS (omask, ACE_Event_Handler::READ_MASK); if (handle_set.wr_mask_.is_set (handle)) ACE_SET_BITS (omask, ACE_Event_Handler::WRITE_MASK); if (handle_set.ex_mask_.is_set (handle)) ACE_SET_BITS (omask, ACE_Event_Handler::EXCEPT_MASK); switch (ops) { case ACE_Reactor::GET_MASK: // The work for this operation is done in all cases at the // begining of the function. break; case ACE_Reactor::CLR_MASK: ptmf = &ACE_Handle_Set::clr_bit; // State was changed. we need to reflect that change in the // dispatch_mask I assume that only ACE_Reactor::CLR_MASK should // be treated here which means we need to clear the handle|mask // from the current dispatch handler this->clear_dispatch_mask (handle, mask); /* FALLTHRU */ case ACE_Reactor::SET_MASK: /* FALLTHRU */ case ACE_Reactor::ADD_MASK: // The following code is rather subtle... Note that if we are // doing a ACE_Reactor::SET_MASK then if the bit is not enabled // in the mask we need to clear the bit from the ACE_Handle_Set. // On the other hand, if we are doing a ACE_Reactor::CLR_MASK or // a ACE_Reactor::ADD_MASK we just carry out the operations // specified by the mask. // READ, ACCEPT, and CONNECT flag will place the handle in the // read set. if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK) || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK) || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) { (handle_set.rd_mask_.*ptmf) (handle); } else if (ops == ACE_Reactor::SET_MASK) handle_set.rd_mask_.clr_bit (handle); // WRITE and CONNECT flag will place the handle in the write set if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK) || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) { (handle_set.wr_mask_.*ptmf) (handle); } else if (ops == ACE_Reactor::SET_MASK) handle_set.wr_mask_.clr_bit (handle); // EXCEPT (and CONNECT on Win32) flag will place the handle in // the except set. if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK) #if defined (ACE_WIN32) || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK) #endif /* ACE_WIN32 */ ) { (handle_set.ex_mask_.*ptmf) (handle); } else if (ops == ACE_Reactor::SET_MASK) handle_set.ex_mask_.clr_bit (handle); break; default: return -1; } return omask; }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::SSLIOP::Acceptor::Acceptor (::Security::QOP qop, const ACE_Time_Value & timeout) : TAO::IIOP_SSL_Acceptor (), ssl_acceptor_ (this), creation_strategy_ (0), concurrency_strategy_ (0), accept_strategy_ (0), timeout_ (timeout) { // --- CSIv1 --- // Clear all bits in the SSLIOP::SSL association option fields. this->ssl_component_.target_supports = 0; this->ssl_component_.target_requires = 0; // SSLIOP requires these Security::AssociationOptions by default. ACE_SET_BITS (this->ssl_component_.target_requires, ::Security::Integrity | ::Security::Confidentiality | ::Security::NoDelegation); // SSLIOP supports these Security::AssociationOptions by default. ACE_SET_BITS (this->ssl_component_.target_supports, ::Security::Integrity | ::Security::Confidentiality | ::Security::EstablishTrustInTarget | ::Security::NoDelegation); // Initialize the default SSL port to zero (wild card port). this->ssl_component_.port = 0; // @@ This should go away once we support setting security // association options through policies. if (qop == ::Security::SecQOPNoProtection) ACE_SET_BITS (this->ssl_component_.target_supports, ::Security::NoProtection); // --- CSIv2 --- // Clear all bits in the CSIIOP::TLS_SEC_TRANS association option // fields. this->csiv2_component_.target_supports = 0; this->csiv2_component_.target_requires = 0; // SSLIOP requires these CSIIOP::AssociationOptions by default. ACE_SET_BITS (this->csiv2_component_.target_requires, CSIIOP::Integrity | CSIIOP::Confidentiality | CSIIOP::NoDelegation); // SSLIOP supports these CSIIOP::AssociationOptions by default. ACE_SET_BITS (this->csiv2_component_.target_supports, CSIIOP::Integrity | CSIIOP::Confidentiality | CSIIOP::EstablishTrustInTarget | CSIIOP::NoDelegation); // @@ This should go away once we support setting security // association options through policies. if (qop == CSIIOP::NoProtection) ACE_SET_BITS (this->csiv2_component_.target_supports, CSIIOP::NoProtection); }
int TAO::SSLIOP::Protocol_Factory::init (int argc, ACE_TCHAR* argv[]) { char *certificate_path = 0; char *private_key_path = 0; char *dhparams_path = 0; char *ca_file = 0; CORBA::String_var ca_dir; ACE_TCHAR *rand_path = 0; int certificate_type = -1; int private_key_type = -1; int dhparams_type = -1; int prevdebug = -1; CSIIOP::AssociationOptions csiv2_target_supports = CSIIOP::Integrity | CSIIOP::Confidentiality; CSIIOP::AssociationOptions csiv2_target_requires = CSIIOP::Integrity | CSIIOP::Confidentiality; // Force the Singleton instance to be initialized/instantiated. // Some SSLIOP option combinations below will result in the // Singleton instance never being initialized. In that case, // problems may occur later on due to lack of initialization of the // underlying SSL library (e.g. OpenSSL), which occurs when an // ACE_SSL_Context is instantiated. // This directive processing initializes ACE_SSL_Context as well // as registers ACE_SSL for correct cleanup. ACE_Service_Config::process_directive ( ACE_STATIC_SERVICE_DIRECTIVE ("ACE_SSL_Initializer", "")); // The code is cleaner this way anyway. ACE_SSL_Context * ssl_ctx = ACE_SSL_Context::instance (); size_t session_id_len = (sizeof session_id_context_ >= SSL_MAX_SSL_SESSION_ID_LENGTH) ? SSL_MAX_SSL_SESSION_ID_LENGTH : sizeof session_id_context_; // Note that this function returns 1, if the operation succeded. // See SSL_CTX_set_session_id_context(3) if( 1 != ::SSL_CTX_set_session_id_context (ssl_ctx->context(), session_id_context_, session_id_len)) { if (TAO_debug_level > 0) ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to set the session id ") ACE_TEXT ("context to \'%C\'\n"), session_id_context_)); return -1; } for (int curarg = 0; curarg != argc; ++curarg) { if ((ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-verbose")) == 0) || (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-v")) == 0)) { if (TAO_debug_level == 0) { prevdebug = TAO_debug_level; TAO_debug_level = 1; } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLNoProtection")) == 0) { // Enable the eNULL cipher. Note that enabling the "eNULL" // cipher only disables encryption. However, certificate // exchanges will still occur. if (::SSL_CTX_set_cipher_list (ssl_ctx->context (), "ALL:eNULL") == 0) { ORBSVCS_DEBUG ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to set eNULL ") ACE_TEXT ("SSL cipher in SSLIOP ") ACE_TEXT ("factory.\n"))); return -1; } // This does not disable secure invocations on the server // side. It merely enables insecure ones. On the client // side, secure invocations will be disabled unless // overridden by a SecurityLevel2::QOPPolicy in the object // reference. this->qop_ = ::Security::SecQOPNoProtection; ACE_SET_BITS (csiv2_target_supports, CSIIOP::NoProtection); ACE_CLR_BITS (csiv2_target_requires, CSIIOP::Confidentiality); } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLCertificate")) == 0) { curarg++; if (curarg < argc) { certificate_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &certificate_path); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLPrivateKey")) == 0) { curarg++; if (curarg < argc) { private_key_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &private_key_path); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLAuthenticate")) == 0) { curarg++; if (curarg < argc) { int mode = SSL_VERIFY_NONE; if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("NONE")) == 0) { mode = SSL_VERIFY_NONE; } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("SERVER")) == 0) { mode = SSL_VERIFY_PEER; ACE_SET_BITS (csiv2_target_supports, CSIIOP::EstablishTrustInTarget | CSIIOP::EstablishTrustInClient); } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("CLIENT")) == 0 || ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("SERVER_AND_CLIENT")) == 0) { mode = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; ACE_SET_BITS (csiv2_target_supports, CSIIOP::EstablishTrustInTarget | CSIIOP::EstablishTrustInClient); ACE_SET_BITS (csiv2_target_requires, CSIIOP::EstablishTrustInClient); } ssl_ctx->default_verify_mode (mode); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLAcceptTimeout")) == 0) { curarg++; if (curarg < argc) { float timeout = 0; if (sscanf (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), "%f", &timeout) != 1 || timeout < 0) ORBSVCS_ERROR_RETURN ((LM_ERROR, "ERROR: Invalid -SSLAcceptTimeout " "value: %s.\n", argv[curarg]), -1); else this->timeout_.set (timeout); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLDHparams")) == 0) { curarg++; if (curarg < argc) { dhparams_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &dhparams_path); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLCAfile")) == 0) { curarg++; if (curarg < argc) { (void) parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &ca_file); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLCApath")) == 0) { curarg++; if (curarg < argc) { ca_dir = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(argv[curarg])); } } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLrand")) == 0) { curarg++; if (curarg < argc) { rand_path = argv[curarg]; } } #if !defined (__Lynx__) else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLServerCipherOrder")) == 0) { ::SSL_CTX_set_options (ssl_ctx->context (), SSL_OP_CIPHER_SERVER_PREFERENCE); } else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-SSLCipherList")) == 0) { curarg++; if (curarg < argc) { if (::SSL_CTX_set_cipher_list (ssl_ctx->context (), ACE_TEXT_ALWAYS_CHAR(argv[curarg])) == 0) { ORBSVCS_DEBUG ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to set cipher ") ACE_TEXT ("list in SSLIOP ") ACE_TEXT ("factory.\n"))); return -1; } } } #endif } // Load some (more) entropy from the user specified sources // in addition to what's pointed to by ACE_SSL_RAND_FILE_ENV if (rand_path != 0) { short errors = 0; ACE_TCHAR *file_name = 0; const ACE_TCHAR *path = ACE_OS::strtok_r (rand_path, TAO_PATH_SEPARATOR_STRING, &file_name); while ( path != 0) { if( -1 == ssl_ctx->seed_file (ACE_TEXT_ALWAYS_CHAR(path), -1)) { ++errors; ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Failed to load ") ACE_TEXT ("more entropy from <%s>: %m\n"), path)); } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Loaded ") ACE_TEXT ("more entropy from <%s>\n"), path)); } path = ACE_OS::strtok_r (0, TAO_PATH_SEPARATOR_STRING, &file_name); } if (errors > 0) return -1; } // Load any trusted certificates explicitely rather than relying on // previously set SSL_CERT_FILE and/or SSL_CERT_PATH environment variable if (ca_file != 0 || ca_dir.in () != 0) { if (ssl_ctx->load_trusted_ca (ca_file, ca_dir.in ()) != 0) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to load ") ACE_TEXT ("CA certs from %C%C%C\n"), ((ca_file != 0) ? ca_file : "a file pointed to by " ACE_SSL_CERT_FILE_ENV " env var (if any)"), ACE_TEXT (" and "), ((ca_dir.in () != 0) ? ca_dir.in () : "a directory pointed to by " ACE_SSL_CERT_DIR_ENV " env var (if any)"))); return -1; } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ") ACE_TEXT ("Trusted Certificates from %C%C%C\n"), ((ca_file != 0) ? ca_file : "a file pointed to by " ACE_SSL_CERT_FILE_ENV " env var (if any)"), ACE_TEXT (" and "), ((ca_dir.in () != 0) ? ca_dir.in () : "a directory pointed to by " ACE_SSL_CERT_DIR_ENV " env var (if any)"))); } } // Load in the DH params. If there was a file explicitly specified, // then we do that here, otherwise we load them in from the cert file. // Note that we only do this on the server side, I think so we might // need to defer this 'til later in the acceptor or something... if (dhparams_path == 0) { // If the user didn't explicitly specify a DH parameters file, we // also might find it concatenated in the certificate file. // So, we set the dhparams to that if it wasn't explicitly set. dhparams_path = certificate_path; dhparams_type = certificate_type; } if (dhparams_path != 0) { if (ssl_ctx->dh_params (dhparams_path, dhparams_type) != 0) { if (dhparams_path != certificate_path) { // We only want to fail catastrophically if the user specified // a dh parameter file and we were unable to actually find it // and load from it. ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) SSLIOP_Factory: ") ACE_TEXT ("unable to set ") ACE_TEXT ("DH parameters <%C>\n"), dhparams_path)); return -1; } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) SSLIOP_Factory: ") ACE_TEXT ("No DH parameters found in ") ACE_TEXT ("certificate <%C>; either none ") ACE_TEXT ("are needed (RSA) or problems ") ACE_TEXT ("will ensue later.\n"), dhparams_path)); } } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) SSLIOP loaded ") ACE_TEXT ("Diffie-Hellman params ") ACE_TEXT ("from %C\n"), dhparams_path)); } } // The certificate must be set before the private key since the // ACE_SSL_Context attempts to check the private key for // consistency. That check requires the certificate to be available // in the underlying SSL_CTX. if (certificate_path != 0) { if (ssl_ctx->certificate (certificate_path, certificate_type) != 0) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to set ") ACE_TEXT ("SSL certificate <%C> ") ACE_TEXT ("in SSLIOP factory.\n"), certificate_path)); return -1; } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ") ACE_TEXT ("SSL certificate ") ACE_TEXT ("from %C\n"), certificate_path)); } } if (private_key_path != 0) { if (ssl_ctx->private_key (private_key_path, private_key_type) != 0) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) Unable to set ") ACE_TEXT ("SSL private key ") ACE_TEXT ("<%C> in SSLIOP factory.\n"), private_key_path)); return -1; } else { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ") ACE_TEXT ("Private Key ") ACE_TEXT ("from <%C>\n"), private_key_path)); } } if (this->register_orb_initializer (csiv2_target_supports, csiv2_target_requires) != 0) return -1; if (prevdebug != -1) TAO_debug_level = prevdebug; return 0; }
void Cubit_Client::disable_test (u_int mask) { ACE_SET_BITS (this->test_disable_bitset_, mask); }
int ACE_Service_Gestalt::open_i (const ACE_TCHAR program_name[], const ACE_TCHAR* logger_key, bool ignore_static_svcs, bool ignore_default_svc_conf_file, bool ignore_debug_flag) { ACE_TRACE ("ACE_Service_Gestalt::open_i"); int result = 0; ACE_Log_Msg *log_msg = ACE_LOG_MSG; this->no_static_svcs_ = ignore_static_svcs; // Record the current log setting upon entering this thread. u_long old_process_mask = log_msg->priority_mask (ACE_Log_Msg::PROCESS); u_long old_thread_mask = log_msg->priority_mask (ACE_Log_Msg::THREAD); #ifndef ACE_NLOGGING if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ") ACE_TEXT ("opened=%d, loadstatics=%d\n"), this, this->is_opened_, this->no_static_svcs_)); #endif // Guard against reentrant processing. For example, // if the singleton gestalt (ubergestalt) was already open, // do not open it again... if (this->is_opened_++ != 0) return 0; if (this->init_i () != 0) return -1; u_long flags = log_msg->flags (); // Only use STDERR if the caller hasn't already set the flags. if (flags == 0) flags = (u_long) ACE_Log_Msg::STDERR; const ACE_TCHAR *key = logger_key; if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) { // Only use the static <logger_key_> if the caller doesn't // override it in the parameter list or if the key supplied is // equal to the default static logger key. key = this->logger_key_; } else { ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); } if (log_msg->open (program_name, flags, key) == -1) return -1; if (!ignore_debug_flag) { // If -d was included as a startup parameter, the user wants debug // information printed during service initialization. if (ACE::debug ()) ACE_Log_Msg::enable_debug_messages (); else // The user has requested no debugging info. ACE_Log_Msg::disable_debug_messages (); } if (!ignore_default_svc_conf_file) { bool add_default = true; bool has_files = this->svc_conf_file_queue_ && !this->svc_conf_file_queue_->is_empty (); bool has_cmdline = this->svc_queue_ && !this->svc_queue_->is_empty (); if (has_files || has_cmdline) { // check if default file is already listed ACE_TString *sptr = 0; ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF); for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_); iter.next (sptr) != 0 && add_default; iter.advance ()) { add_default = (*sptr != default_svc_conf); } if (add_default) { FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, ACE_TEXT ("r")); if (fp != 0) ACE_OS::fclose(fp); else add_default = false; } } // Load the default "svc.conf" entry. here if there weren't // overriding -f arguments in <parse_args>. if (add_default && svc_conf_file_queue_->enqueue_head (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) { errno = ENOENT; ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("enqueuing ") ACE_DEFAULT_SVC_CONF ACE_TEXT(" file")), -1); } } // See if we need to load the static services. if (this->no_static_svcs_ == 0 && this->load_static_svcs () == -1) result = -1; else { result = this->process_directives (); if (result != -1) { int temp = this->process_commandline_directives (); if (temp == -1) result = -1; else result += temp; } } // Reset debugging back to the way it was when we came into // into <open_i>. { // Make sure to save/restore errno properly. ACE_Errno_Guard error (errno); if (!ignore_debug_flag) { log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS); log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD); } } return result; } /* open_i () */