ACE_Strategy_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Strategy_Connector (ACE_Reactor *reactor, ACE_Creation_Strategy<SVC_HANDLER> *cre_s, ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> *conn_s, ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, int flags) : base_type (reactor), creation_strategy_ (0), delete_creation_strategy_ (false), connect_strategy_ (0), delete_connect_strategy_ (false), concurrency_strategy_ (0), delete_concurrency_strategy_ (false) { ACE_TRACE ("ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::ACE_Strategy_Connector"); if (this->open (reactor, cre_s, conn_s, con_s, flags) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Strategy_Connector::ACE_Strategy_Connector"))); }
ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads, bool used_with_reactor_event_loop) : completion_port_ (0), // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!! number_of_threads_ (static_cast<DWORD> (number_of_threads)), used_with_reactor_event_loop_ (used_with_reactor_event_loop) { // Create the completion port. this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE, 0, 0, this->number_of_threads_); if (this->completion_port_ == 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("CreateIoCompletionPort"))); this->get_asynch_pseudo_task ().start (); }
ACE_DLL::ACE_DLL (const ACE_DLL &rhs) : open_mode_ (0), dll_name_ (0), close_handle_on_destruction_ (false), dll_handle_ (0), error_ (0) { ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)"); if (rhs.dll_name_ // This will automatically up the refcount. && this->open (rhs.dll_name_, rhs.open_mode_, rhs.close_handle_on_destruction_) != 0 && ACE::debug ()) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE_DLL::copy_ctor: error: %s\n"), this->error ())); }
void Linux_Network_Interface_Monitor::init (void) { for (unsigned long i = 0UL; i < MAX_INTERFACES; ++i) { this->value_array_[i] = 0UL; } /// Read the file once to get a base value that we can subtract /// from subsequent readings to get bytes sent since we started /// monitoring. char buf[1024]; FILE* fp = ACE_OS::fopen (ACE_TEXT ("/proc/net/dev"), ACE_TEXT ("r")); if (fp == 0) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("bytes sent - opening ") ACE_TEXT ("/proc/net/dev failed\n"))); return; } /// Ignore the first 2 lines of the file, which are file /// and column headers. void* dummy = ACE_OS::fgets (buf, sizeof (buf), fp); ACE_UNUSED_ARG (dummy); dummy = ACE_OS::fgets (buf, sizeof (buf), fp); ACE_UNUSED_ARG (dummy); unsigned long iface_value = 0UL; ACE_UINT32 iface_index = 0UL; while (ACE_OS::fgets (buf, sizeof (buf), fp) != 0) { sscanf (buf, this->scan_format_.c_str (), &iface_value); this->start_ += iface_value; ++iface_index; } (void) ACE_OS::fclose (fp); }
ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream (ACE_SSL_Context *context) : ssl_ (0), stream_ () { ACE_TRACE ("ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream"); ACE_SSL_Context * ctx = (context == 0 ? ACE_SSL_Context::instance () : context); this->ssl_ = ::SSL_new (ctx->context ()); if (this->ssl_ == 0) { ACELIB_ERROR ((LM_ERROR, "(%P|%t) ACE_SSL_SOCK_Stream " "- cannot allocate new SSL structure %p\n", ACE_TEXT (""))); } }
ACE_Process_Manager::ACE_Process_Manager (size_t size, ACE_Reactor *r) : ACE_Event_Handler (), process_table_ (0), max_process_table_size_ (0), current_count_ (0), default_exit_handler_ (0) #if defined (ACE_HAS_THREADS) , lock_ () #endif /* ACE_HAS_THREADS */ { ACE_TRACE ("ACE_Process_Manager::ACE_Process_Manager"); if (this->open (size, r) == -1) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Process_Manager"))); } }
ACE_SOCK::ACE_SOCK (int type, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) { // ACE_TRACE ("ACE_SOCK::ACE_SOCK"); if (this->open (type, protocol_family, protocol, protocolinfo, g, flags, reuse_addr) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK::ACE_SOCK"))); }
ACE_Event_T<TIME_POLICY>::ACE_Event_T (int manual_reset, int initial_state, int type, const ACE_TCHAR *name, void *arg, LPSECURITY_ATTRIBUTES sa) : ACE_Event_Base () { ACE_Condition_Attributes_T<TIME_POLICY> cond_attr (type); if (ACE_OS::event_init (&this->handle_, type, &const_cast<ACE_condattr_t&> (cond_attr.attributes ()), manual_reset, initial_state, name, arg, sa) != 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Event_T<TIME_POLICY>::ACE_Event_T"))); }
void ACE_Token_Proxy_Queue::dequeue (void) { ACE_TRACE ("ACE_Token_Proxy_Queue::dequeue"); if (head_ == 0) return; ACE_TPQ_Entry *temp = this->head_; this->head_ = this->head_->next_; temp->next_ = 0; --this->size_; if (this->head_ == 0 && this->size_ != 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("incorrect size = %d\n"), this->size_)); }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_System_Time::ACE_System_Time (const ACE_TCHAR *poolname) : shmem_ (0) , delta_time_ (0) { ACE_TRACE ("ACE_System_Time::ACE_System_Time"); // Only create a new unique filename for the memory pool file // if the user didn't supply one... if (poolname == 0) { #if defined (ACE_DEFAULT_BACKING_STORE) // Create a temporary file. ACE_OS::strcpy (this->poolname_, ACE_DEFAULT_BACKING_STORE); #else /* ACE_DEFAULT_BACKING_STORE */ if (ACE::get_temp_dir (this->poolname_, 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->poolname_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->poolname_, ACE_TEXT ("ace-malloc-XXXXXX")); #endif /* ACE_DEFAULT_BACKING_STORE */ } else ACE_OS::strsncpy (this->poolname_, poolname, (sizeof this->poolname_ / sizeof (ACE_TCHAR))); ACE_NEW (this->shmem_, ALLOCATOR (this->poolname_)); }
ACE_Service_Type_Impl * ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name, int type, void *symbol, u_int flags, ACE_Service_Object_Exterminator gobbler) { ACE_Service_Type_Impl *stp = 0; // Note, the only place we need to put a case statement. This is // also the place where we'd put the RTTI tests, if the compiler // actually supported them! switch (type) { case ACE_Service_Type::SERVICE_OBJECT: ACE_NEW_RETURN (stp, ACE_Service_Object_Type ((ACE_Service_Object *) symbol, name, flags, gobbler), 0); break; case ACE_Service_Type::MODULE: ACE_NEW_RETURN (stp, ACE_Module_Type (symbol, name, flags), 0); break; case ACE_Service_Type::STREAM: ACE_NEW_RETURN (stp, ACE_Stream_Type (symbol, name, flags), 0); break; default: ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("unknown case\n"))); break; } return stp; }
void CPU_Load_Monitor::access_proc_stat (unsigned long *which_idle) { this->file_ptr_ = ACE_OS::fopen (ACE_TEXT ("/proc/stat"), ACE_TEXT ("r")); if (this->file_ptr_ == 0) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("CPU load - opening /proc/stat failed\n"))); return; } char *item = 0; char *arg = 0; while ((ACE_OS::fgets (buf_, sizeof (buf_), file_ptr_)) != 0) { item = ACE_OS::strtok (this->buf_, " \t\n"); arg = ACE_OS::strtok (0, "\n"); if (item == 0 || arg == 0) { continue; } if (ACE_OS::strcmp (item, "cpu") == 0) { sscanf (arg, "%lu %lu %lu %lu", &this->user_, &this->wait_, &this->kernel_, which_idle); break; } } ACE_OS::fclose (this->file_ptr_); }
// Trigger reconfiguration to re-read configuration files. void ACE_Service_Config::reconfigure (void) { ACE_TRACE ("ACE_Service_Config::reconfigure"); ACE_Service_Config::reconfig_occurred_ = 0; if (ACE::debug ()) { #if !defined (ACE_NLOGGING) time_t t = ACE_OS::time (0); #endif /* ! ACE_NLOGGING */ if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("beginning reconfiguration at %s"), ACE_OS::ctime (&t))); } if (ACE_Service_Config::process_directives () == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("process_directives"))); }
ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr, int protocol_family, int backlog, int protocol) { ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor"); if (this->open (local_sap, protocolinfo, g, flags, reuse_addr, protocol_family, backlog, protocol) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SOCK_Acceptor"))); }
int ACE_Proactor::close (void) { // Close the implementation. if (this->implementation ()->close () == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%N:%l:(%P | %t):%p\n"), ACE_TEXT ("ACE_Proactor::close: implementation close"))); // Delete the implementation. if (this->delete_implementation_) { delete this->implementation (); this->implementation_ = 0; } // Delete the timer handler. if (this->timer_handler_) { delete this->timer_handler_; this->timer_handler_ = 0; } // Delete the timer queue. if (this->delete_timer_queue_) { delete this->timer_queue_; this->timer_queue_ = 0; this->delete_timer_queue_ = 0; } else if (this->timer_queue_) { this->timer_queue_->close (); this->timer_queue_ = 0; } return 0; }
void * ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, bool ignore_errors, ACE_TString &error) { ACE_TRACE ("ACE_DLL_Handle::symbol"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); ACE_Auto_Array_Ptr <ACE_TCHAR> auto_name (ACE::ldname (sym_name)); // handle_ can be invalid especially when ACE_DLL_Handle resigned ownership // BTW. Handle lifecycle management is a little crazy in ACE if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) { #if defined (ACE_OPENVMS) void *sym = ACE::ldsymbol (this->handle_, auto_name.get ()); #else void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ()); #endif // Linux says that the symbol could be null and that it isn't an // error. So you should check the error message also, but since // null symbols won't do us much good anyway, let's still report // an error. if (!sym && !ignore_errors) { this->error (error); if (ACE::debug ()) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ") ACE_TEXT (" failed with \"%s\".\n"), auto_name.get (), error.c_str ())); return 0; } return sym; } return 0; }
ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &addr, ACE_Reactor *reactor, ACE_Creation_Strategy<SVC_HANDLER> *cre_s, ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> *acc_s, ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, ACE_Scheduling_Strategy<SVC_HANDLER> *sch_s, const ACE_TCHAR service_name[], const ACE_TCHAR service_description[], int use_select, int reuse_addr) : creation_strategy_ (0), delete_creation_strategy_ (false), accept_strategy_ (0), delete_accept_strategy_ (false), concurrency_strategy_ (0), delete_concurrency_strategy_ (false), scheduling_strategy_ (0), delete_scheduling_strategy_ (false), service_name_ (0), service_description_ (0) { ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor"); if (this->open (addr, reactor, cre_s, acc_s, con_s, sch_s, service_name, service_description, use_select, reuse_addr) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"))); }
// ************************************************************ // ACE_SSL_Asynch_Stream Constructor / Destructor // ************************************************************ ACE_SSL_Asynch_Stream::ACE_SSL_Asynch_Stream ( ACE_SSL_Asynch_Stream::Stream_Type s_type, ACE_SSL_Context * context) : type_ (s_type), proactor_ (0), ext_handler_ (0), ext_read_result_ (0), ext_write_result_(0), flags_ (0), ssl_ (0), handshake_complete_(false), bio_ (0), bio_istream_ (), bio_inp_msg_ (), bio_inp_errno_(0), bio_inp_flag_ (0), bio_ostream_ (), bio_out_msg_ (), bio_out_errno_(0), bio_out_flag_ (0), mutex_ () { ACE_TRACE ("ACE_SSL_Asynch_Stream::ACE_SSL_Asynch_Stream"); // was honestly copied from ACE_SSL_SOCK_Stream :) ACE_SSL_Context * ctx = (context == 0 ? ACE_SSL_Context::instance () : context); this->ssl_ = ::SSL_new (ctx->context ()); if (this->ssl_ == 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) ACE_SSL_Asynch_Stream %p\n"), ACE_TEXT ("- cannot allocate new SSL structure") )); }
int ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) { if (sa.get_type () == AF_ANY) { #if defined (ACE_DEFAULT_TEMP_FILE) // Create a temporary file. ACE_OS::strcpy (this->filename_, ACE_DEFAULT_TEMP_FILE); #else /* ACE_DEFAULT_TEMP_FILE */ if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 15) == -1) // -15 for ace-file-XXXXXX { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->filename_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->filename_, ACE_TEXT ("ace-fileXXXXXX")); #endif /* ACE_DEFAULT_TEMP_FILE */ if (ACE_OS::mktemp (this->filename_) == 0) return -1; this->base_set (AF_FILE, static_cast<int> (ACE_OS::strlen (this->filename_) + 1)); } else { (void)ACE_OS::strsncpy (this->filename_, sa.filename_, sa.get_size ()); this->base_set (sa.get_type (), sa.get_size ()); } return 0; }
My_ACE_Logging_Strategy::My_ACE_Logging_Strategy (void) : thread_priority_mask_ (0), process_priority_mask_ (0), flags_ (0), filename_ (0), logger_key_ (0), program_name_ (0), wipeout_logfile_ (false), fixed_number_ (false), order_files_ (false), count_ (0), max_file_number_ (1), // 2 files by default (max file number + 1) interval_ (ACE_DEFAULT_LOGFILE_POLL_INTERVAL), max_size_ (0), log_msg_ (ACE_Log_Msg::instance ()) { #if defined (ACE_DEFAULT_LOGFILE) this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE); #else /* ACE_DEFAULT_LOGFILE */ ACE_NEW (this->filename_, ACE_TCHAR[MAXPATHLEN + 1]); // Get the temporary directory if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 7) == -1) // 7 for "logfile" { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->filename_[0] = 0; } // Add the filename to the end ACE_OS::snprintf(this->filename_, MAXPATHLEN, "%s%s", this->filename_, ACE_TEXT("logfile")); #endif /* ACE_DEFAULT_LOGFILE */ }
int ACE_Remote_Token_Proxy::release (ACE_Synch_Options &options) { ACE_TRACE ("ACE_Remote_Token_Proxy::release"); ACE_Token_Request request (token_->type (), this->type (), ACE_Token_Request::RELEASE, this->name (), this->client_id (), options); int result = this->request_reply (request, options); if (result == 0) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) released %s remotely.\n"), this->name ())); // whether success or failure, we're going to release the shadow. // If race conditions exist such that we are no longer the owner, // this release will perform a remove. if (ACE_Token_Proxy::release () == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%t) shadow: release failed\n"))); return result; }
Monitor_Control_Types::NameList Monitor_Base::get_list (void) const { Monitor_Control_Types::NameList retval; if (this->data_.type_ != Monitor_Control_Types::MC_LIST) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("get_list: %s is not a ") ACE_TEXT ("list monitor type\n"), this->name_.c_str ())); return retval; } ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, retval); for (size_t i = 0UL; i < this->data_.index_; ++i) { retval.push_back (this->data_.list_[i]); } return retval; }
int ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name) { ACE_TRACE ("ACE_SOCK_Dgram_Bcast::mk_broadcast"); int one = 1; if (ACE_OS::setsockopt (this->get_handle (), SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof one) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT("%p\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: setsockopt failed")), -1); #if !defined (ACE_WIN32) && !defined(__INTERIX) ACE_HANDLE s = this->get_handle (); char buf[BUFSIZ]; struct ifconf ifc; ifc.ifc_len = sizeof buf; ifc.ifc_buf = buf; // Get interface structure and initialize the addresses using UNIX // techniques. if (ACE_OS::ioctl (s, SIOCGIFCONF, (char *) &ifc) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT("%p\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface configuration)")), ACE_INVALID_HANDLE); struct ifreq *ifr = ifc.ifc_req; struct sockaddr_in host_addr; // Get host ip address if (host_name) { hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); if (hp == 0) return -1; else ACE_OS::memcpy ((char *) &host_addr.sin_addr.s_addr, # ifdef ACE_HOSTENT_H_ADDR (char *) hp->ACE_HOSTENT_H_ADDR, # else (char *) hp->h_addr, # endif hp->h_length); } #if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__) for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0; n--, ifr++) #else /* There are addresses longer than sizeof (struct sockaddr) eg. IPv6 or QNX::links. In this case address does not fit into struct ifreq. The code below could be applied everywhere, but not every system provides sockaddr.sa_len field. */ for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) && ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1); ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len, ifr = (struct ifreq *) ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) : (nbytes -= sizeof (struct ifreq), ifr++))) #endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__) */ { #if defined (__QNX__) || defined (ACE_VXWORKS) // Silently skip link interfaces if (ifr->ifr_addr.sa_family == AF_LINK) continue; #endif /* __QNX__ || ACE_VXWORKS */ // Compare host ip address with interface ip address. if (host_name) { struct sockaddr_in if_addr; ACE_OS::memcpy (&if_addr, &ifr->ifr_addr, sizeof if_addr); if (host_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) continue; } if (ifr->ifr_addr.sa_family != AF_INET) { // Note that some systems seem to generate 0 (AF_UNDEF) for // the sa_family, even when there are no errors! Thus, we // only print an error if this is not the case, or if we're // in "debugging" mode. if (ifr->ifr_addr.sa_family != 0 || ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT("warning %p: sa_family: %d\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: Not AF_INET"), ifr->ifr_addr.sa_family)); continue; } struct ifreq flags = *ifr; struct ifreq if_req = *ifr; if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p [%s]\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface flags)"), flags.ifr_name)); continue; } if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_UP) == 0) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p [%s]\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: Network interface is not up"), flags.ifr_name)); continue; } if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) continue; if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) { if (ACE_OS::ioctl (s, SIOCGIFBRDADDR, (char *) &if_req) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p [%s]\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get broadaddr)"), flags.ifr_name)); else { ACE_INET_Addr addr (reinterpret_cast <sockaddr_in *> (&if_req.ifr_broadaddr), sizeof if_req.ifr_broadaddr); ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); } } else { if (host_name != 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p [%s]\n"), ACE_TEXT("ACE_SOCK_Dgram_Bcast::mk_broadcast: Broadcast is not enabled for this interface."), flags.ifr_name)); } } #else ACE_UNUSED_ARG (host_name); ACE_INET_Addr addr (u_short (0), ACE_UINT32 (INADDR_BROADCAST)); ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); #endif /* !ACE_WIN32 && !__INTERIX */ if (this->if_list_ == 0) { errno = ENXIO; return -1; } else return 0; }
void * ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config, int &yyerrno, ACE_Service_Object_Exterminator *gobbler) { ACE_TRACE ("ACE_Static_Function_Node::symbol"); this->symbol_ = 0; // Locate the factory function <function_name> in the statically // linked svcs. ACE_Static_Svc_Descriptor *ssd = 0; if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1) { ++yyerrno; if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) No static service ") ACE_TEXT ("registered for function %s\n"), this->function_name_)); } return 0; } if (ssd->alloc_ == 0) { ++yyerrno; if (this->symbol_ == 0) { ++yyerrno; if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) No static service factory ") ACE_TEXT ("function registered for function %s\n"), this->function_name_)); } return 0; } } // Invoke the factory function and record it's return value. this->symbol_ = (*ssd->alloc_) (gobbler); if (this->symbol_ == 0) { ++yyerrno; if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), this->function_name_)); } return 0; } return this->symbol_; }
void * ACE_Function_Node::symbol (ACE_Service_Gestalt *, int &yyerrno, ACE_Service_Object_Exterminator *gobbler) { typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr) (ACE_Service_Object_Exterminator *); ACE_TRACE ("ACE_Function_Node::symbol"); if (this->open_dll (yyerrno) == 0) { this->symbol_ = 0; // Locate the factory function <function_name> in the shared // object. ACE_TCHAR * const function_name = const_cast<ACE_TCHAR *> (this->function_name_); void * const func_p = this->dll_.symbol (function_name); if (func_p == 0) { ++yyerrno; #ifndef ACE_NLOGGING if (ACE::debug ()) { ACE_TCHAR * const errmsg = this->dll_.error (); ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("DLL::symbol failed for function %s: ") ACE_TEXT ("%s\n"), function_name, errmsg ? errmsg : ACE_TEXT ("no error reported"))); } #endif /* ACE_NLOGGING */ return 0; } #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) int const temp_p = reinterpret_cast<int> (func_p); #else intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p); #endif ACE_Service_Factory_Ptr func = reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p); // Invoke the factory function and record it's return value. this->symbol_ = (*func) (gobbler); if (this->symbol_ == 0) { ++yyerrno; if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), this->function_name_)); } return 0; } } return this->symbol_; }
void ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno) { ACE_TRACE ("ACE_Stream_Node::apply"); const ACE_Service_Type *sst = this->node_->record (config); if (sst == 0) const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno); if (yyerrno != 0) return; sst = this->node_->record (config); ACE_Stream_Type *st = dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ())); // The modules were linked as popped off the yacc stack, so they're in // reverse order from the way they should be pushed onto the stream. // So traverse mods_ and and reverse the list, then iterate over it to push // the modules in the stream in the correct order. std::list<const ACE_Static_Node *> mod_list; const ACE_Static_Node *module; for (module = dynamic_cast<const ACE_Static_Node*> (this->mods_); module != 0; module = dynamic_cast<ACE_Static_Node*> (module->link())) mod_list.push_front (module); std::list<const ACE_Static_Node *>::const_iterator iter; for (iter = mod_list.begin (); iter != mod_list.end (); ++iter) { module = *iter; ACE_ARGV args (module->parameters ()); const ACE_Service_Type *mst = module->record (config); if (mst == 0) const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno); if (yyerrno != 0) { if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("dynamic initialization failed for Module %s\n"), module->name ())); } ++yyerrno; continue; // Don't try anything else with this one } ACE_Module_Type const * const mt1 = static_cast <ACE_Module_Type const *> (module->record (config)->type()); ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1); if (st->push (mt) == -1) { if (ACE::debug ()) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("dynamic initialization failed for Stream %s\n"), this->node_->name ())); } ++yyerrno; } } #ifndef ACE_NLOGGING if (ACE::debug ()) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"), this->node_->name (), yyerrno)); #endif /* ACE_NLOGGING */ }
int ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *) { ACE_TRACE ("ACE_Shared_Memory_Pool::handle_signal"); // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("signal %S occurred\n"), signum)); // While FreeBSD 5.X has a siginfo_t struct with a si_addr field, // it does not define SEGV_MAPERR. #if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) && \ (defined (SEGV_MAPERR) || defined (SEGV_MEMERR)) ACE_OFF_T offset; // Make sure that the pointer causing the problem is within the // range of the backing store. if (siginfo != 0) { // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr)); size_t counter; if (this->in_use (offset, counter) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("in_use"))); else if (!(siginfo->si_code == SEGV_MAPERR && siginfo->si_addr < (((char *) this->base_addr_) + offset) && siginfo->si_addr >= ((char *) this->base_addr_))) ACELIB_ERROR_RETURN ((LM_ERROR, "(%P|%t) address %u out of range\n", siginfo->si_addr), -1); } // The above if case will check to see that the address is in the // proper range. Therefore there is a segment out there that the // pointer wants to point into. Find the segment that someone else // has used and attach to it ([email protected]) size_t counter; // ret value to get shmid from the st table. if (this->find_seg (siginfo->si_addr, offset, counter) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("in_use")), -1); void *address = (void *) (((char *) this->base_addr_) + offset); SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_); void *shmem = ACE_OS::shmat (st[counter].shmid_, (char *) address, 0); if (shmem != address) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) %p, shmem = %u, address = %u\n"), ACE_TEXT("shmat"), shmem, address), -1); // NOTE: this won't work if we dont have SIGINFO_T or SI_ADDR #else ACE_UNUSED_ARG (siginfo); #endif /* ACE_HAS_SIGINFO_T && !defined (ACE_LACKS_SI_ADDR) */ return 0; }
void Solaris_Network_Interface_Monitor::access_kstats ( ACE_UINT64 &which_member) { this->kstats_ = kstat_open (); if (this->kstats_ == 0) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("opening kstats file failed\n"))); return; } this->kstat_id_ = this->kstats_->kc_chain_id; int status = 0; while (true) { /// We have to sum the network interfaces manually. for (this->kstat_ = this->kstats_->kc_chain; this->kstat_ != 0; this->kstat_ = this->kstat_->ks_next) { if (ACE_OS::strcmp (this->kstat_->ks_class, "net") != 0) { continue; } unsigned long ks_instance = this->kstat_->ks_instance; if (ACE_OS::strcmp (this->kstat_->ks_module, "lo") == 0) { /// Interfaces 'lo' have only packet counters. if (this->lookup_str_ == ACE_TEXT ("obytes") || this->lookup_str_ == ACE_TEXT ("rbytes")) { continue; } status = this->check_ks_module (ks_instance, MAX_LO_INTERFACES, "MAX_LO_INTERFACES", this->value_array_lo_, which_member); if (status == -1) { /// Unrecoverable error, diagnostic already output. (void) kstat_close (this->kstats_); return; } else if (status == 1) { /// The kstat_id changed underneath us, start over. break; } } else if (ACE_OS::strcmp (this->kstat_->ks_module, "hme") == 0 || ACE_OS::strcmp (this->kstat_->ks_module, "bge") == 0) { status = this->check_ks_module (ks_instance, MAX_HME_INTERFACES, "MAX_HME_INTERFACES", this->value_array_hme_, which_member); if (status == -1) { /// Unrecoverable error, diagnostic already output. (void) kstat_close (this->kstats_); return; } else if (status == 1) { /// The kstat_id changed underneath us, start over. break; } } } if (this->kstat_) { this->kstat_id_ = kstat_chain_update (this->kstats_); if (! this->kstat_id_ > 0) { ACELIB_ERROR ((LM_ERROR, "kstat is is not > 0.\n")); break; } } else { break; } } status = kstat_close (this->kstats_); if (status != 0) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("closing kstats file failed\n"))); } }
int ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream, ACE_MEM_Addr *remote_sap, ACE_Time_Value *timeout, bool restart, bool reset_new_handle) { ACE_TRACE ("ACE_MEM_Acceptor::accept"); int in_blocking_mode = 1; if (this->shared_accept_start (timeout, restart, in_blocking_mode) == -1) return -1; else { sockaddr *addr = 0; struct sockaddr_in inet_addr; int *len_ptr = 0; int len = 0; if (remote_sap != 0) { addr = reinterpret_cast<sockaddr *> (&inet_addr); len = sizeof (inet_addr); len_ptr = &len; } do // On Win32 the third parameter to <accept> must be a NULL // pointer if to ignore the client's address. new_stream.set_handle (ACE_OS::accept (this->get_handle (), addr, len_ptr)); while (new_stream.get_handle () == ACE_INVALID_HANDLE && restart != 0 && errno == EINTR && timeout == 0); if (remote_sap != 0) { ACE_INET_Addr temp (&inet_addr, len); remote_sap->set_port_number (temp.get_port_number ()); } } if (this->shared_accept_finish (new_stream, in_blocking_mode, reset_new_handle) == -1) return -1; // Allocate 2 * MAXPATHLEN so we can accomodate the unique // name that gets appended later ACE_TCHAR buf [2 * MAXPATHLEN + 1]; ACE_INET_Addr local_addr; if (new_stream.get_local_addr (local_addr) == -1) return -1; if (this->mmap_prefix_ != 0) { ACE_OS::sprintf (buf, ACE_TEXT ("%s_%d_"), this->mmap_prefix_, local_addr.get_port_number ()); } else { ACE_TCHAR name[25]; // - 24 is so we can append name to the end. if (ACE::get_temp_dir (buf, MAXPATHLEN - 24) == -1) { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); buf[0] = 0; } ACE_OS::sprintf (name, ACE_TEXT ("MEM_Acceptor_%d_"), local_addr.get_port_number ()); ACE_OS::strcat (buf, name); } ACE_TCHAR unique [MAXPATHLEN]; ACE_OS::unique_name (&new_stream, unique, MAXPATHLEN); ACE_OS::strcat (buf, unique); // Make sure we have a fresh start. ACE_OS::unlink (buf); new_stream.disable (ACE_NONBLOCK); ACE_HANDLE new_handle = new_stream.get_handle (); // Protocol negociation: // Tell the client side what level of signaling strategy // we support. ACE_MEM_IO::Signal_Strategy client_signaling = #if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM) this->preferred_strategy_; #else // We don't support MT. ACE_MEM_IO::Reactive; #endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */ if (ACE::send (new_handle, &client_signaling, sizeof (ACE_INT16)) == -1) ACELIB_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("ACE_MEM_Acceptor::accept error sending strategy\n")), -1); // Now we get the signaling strategy the client support. if (ACE::recv (new_handle, &client_signaling, sizeof (ACE_INT16)) == -1) ACELIB_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("ACE_MEM_Acceptor::%p error receiving strategy\n"), ACE_TEXT ("accept")), -1); // Ensure minimum buffer size if (this->malloc_options_.minimum_bytes_ < ACE_MEM_STREAM_MIN_BUFFER) this->malloc_options_.minimum_bytes_ = ACE_MEM_STREAM_MIN_BUFFER; // Client will decide what signaling strategy to use. // Now set up the shared memory malloc pool. if (new_stream.init (buf, static_cast<ACE_MEM_IO::Signal_Strategy> (client_signaling), &this->malloc_options_) == -1) return -1; // @@ Need to handle timeout here. ACE_UINT16 buf_len = static_cast<ACE_UINT16> ((ACE_OS::strlen (buf) + 1) * sizeof (ACE_TCHAR)); // No need to worry about byte-order because both parties should always // be on the same machine. if (ACE::send (new_handle, &buf_len, sizeof (ACE_UINT16)) == -1) return -1; // Now send the pathname of the mmap file. if (ACE::send (new_handle, buf, buf_len) == -1) return -1; return 0; }
int ACE_Service_Gestalt::initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters) { ACE_TRACE ("ACE_Service_Gestalt_Base::initialize (repo)"); ACE_ARGV args (parameters); #ifndef ACE_NLOGGING if (ACE::debug ()) { ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SG::initialize - () repo=%@, ") ACE_TEXT ("looking up static ") ACE_TEXT ("service \'%s\' to initialize\n"), this->repo_, svc_name)); } #endif const ACE_Service_Type *srp = 0; for (int i = 0; this->find (svc_name, &srp) == -1 && i < 2; i++) // if (this->repo_->find (svc_name, &srp) == -1) { const ACE_Static_Svc_Descriptor *assd = ACE_Service_Config::global()->find_processed_static_svc(svc_name); if (assd != 0) { this->process_directive_i(*assd, 0); } else { ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") ACE_TEXT (" was not located.\n"), svc_name), -1); } } if (srp == 0) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") ACE_TEXT (" was not located.\n"), svc_name), -1); /// If initialization fails ... if (srp->type ()->init (args.argc (), args.argv ()) == -1) { // ... report and remove this entry. ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - static init of \'%s\'") ACE_TEXT (" failed (%p)\n"), svc_name, ACE_TEXT ("error"))); this->repo_->remove (svc_name); return -1; } // If everything is ok, activate it const_cast<ACE_Service_Type *>(srp)->active (1); return 0; }