int mod_init(void) { mp_cache_init(&mod_cache, module_t); load_modules(); return 0; }
int main (int argc, char *argv []) { SifInitRpc (0); init_scr (); scr_printf (APP_NAME "-" VERSION "\n"); /* decide whether to load TCP/IP or it is already loaded */ SifExitIopHeap (); SifLoadFileExit (); SifExitRpc (); SifIopReset (NULL /* "rom0:UDNL rom0:EELOADCNF" */, 0); while (SifIopSync ()) ; SifInitRpc (0); if (load_modules () == 0) { scr_printf ("Ready\n"); } else scr_printf ("Failed to load\n"); /* our job is done; IOP would handle the rest */ SleepThread (); return (0); }
void special_mod(const char *spec_mod) { int i = 0, j = 0; char mod_name[LEN_32]; struct module *mod = NULL; memset(mod_name, 0, LEN_32); sprintf(mod_name, "mod_%s", spec_mod + 5); for ( i = 0; i < statis.total_mod_num; i++ ) { mod = mods[i]; if (!strcmp(mod->name, mod_name)) { /* set special field */ load_modules(); char *token = strtok(NULL, W_SPACE); struct mod_info *info = mod->info; for (j=0; j < mod->n_col; j++) { char *p = info[j].hdr; while (*p == ' ') { p++; } if (strstr(token, p)) { info[j].summary_bit = SPEC_BIT; mod->spec = 1; } } } } }
PyMODINIT_FUNC initgwy(void) { gchar *settings_file; PyObject *mod, *dict; if (!reload_libraries()) return; /* gwybatch.c */ /* This requires a display. */ gtk_init(NULL, NULL); gwy_widgets_type_init(); gwy_undo_set_enabled(FALSE); gwy_resource_class_load(g_type_class_peek(GWY_TYPE_GRADIENT)); gwy_resource_class_load(g_type_class_peek(GWY_TYPE_GL_MATERIAL)); gwy_resource_class_load(g_type_class_peek(GWY_TYPE_GRAIN_VALUE)); gwy_resource_class_load(g_type_class_peek(GWY_TYPE_CALIBRATION)); settings_file = gwy_app_settings_get_settings_filename(); gwy_app_settings_load(settings_file, NULL); g_free(settings_file); /* This requires a display. */ gwy_stock_register_stock_items(); load_modules(); /* pygwy.c */ init_pygobject(); mod = Py_InitModule("gwy", (PyMethodDef*)pygwy_functions); dict = PyModule_GetDict(mod); /* This does "import gtk" so display is required. */ pygwy_register_classes(dict); pygwy_add_constants(mod, "GWY_"); }
void plugin_factory_collection::load_modules(const filesystem::path& Path, const bool Recursive, const load_proxy_t LoadProxies) { m_implementation->m_message_signal.emit(string_cast(boost::format(_("Searching for plugins in %1%")) % Path.native_utf8_string().raw())); // Create a sorted list of files in this directory ... std::vector<filesystem::path> files; for(k3d::filesystem::directory_iterator path(Path); path != k3d::filesystem::directory_iterator(); ++path) files.push_back(*path); std::sort(files.begin(), files.end()); // Load modules for(std::vector<filesystem::path>::const_iterator file = files.begin(); file != files.end(); ++file) { if(!filesystem::is_directory(*file)) load_module(*file, LoadProxies); } // Optionally descend recursively into subdirectories ... if(Recursive) { for(std::vector<filesystem::path>::const_iterator file = files.begin(); file != files.end(); ++file) { if(filesystem::is_directory(*file)) load_modules(*file, Recursive, LoadProxies); } } }
int main (int argc, char **argv) { UniqueApp *app; GtkWidget *window; g_thread_init (NULL); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &argv); /* TODO: use GOption to parse arguments */ app = unique_app_new_with_commands ("com.intel.Bisho", NULL, "callback", COMMAND_CALLBACK, NULL); if (unique_app_is_running (app)) { UniqueResponse response; if (argc != 2) { response = unique_app_send_message (app, UNIQUE_ACTIVATE, NULL); } else { UniqueMessageData *msg; msg = unique_message_data_new (); unique_message_data_set_uris (msg, argv + 1); response = unique_app_send_message (app, COMMAND_CALLBACK, msg); unique_message_data_free (msg); } if (response == UNIQUE_RESPONSE_OK) goto done; } load_modules (); window = bisho_window_new (); unique_app_watch_window (app, GTK_WINDOW (window)); g_signal_connect (app, "message-received", G_CALLBACK (unique_message_cb), window); g_signal_connect (window, "delete-event", gtk_main_quit, NULL); gtk_widget_show (window); gtk_main (); done: g_object_unref (app); return 0; }
init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) { char *path = modules_path(mem_ctx, subsystem); init_module_fn *ret; ret = load_modules(mem_ctx, path); talloc_free(path); return ret; }
RequestHandler::RequestHandler( const std::string &method ) { // initialise defaults _handlers_count = 0; _handlers = NULL; // update variables _req_handler.method = method; // load modifier modules load_modules(); }
int main(int argc, char**argv) { /* clear the EZTRACE_TRACE environment variable so that all the available modules are listed */ unsetenv("EZTRACE_TRACE"); /* parse the arguments passed to this program */ parse_args (argc, argv); load_modules(0); eztrace_convert_list(); return 0; }
int backend_init(const char *moddir) { if (!moddir || !*moddir) { errno = EINVAL; return -1; } if (backends) return 0; backends = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)free_backend); if (!backends) { errno = ENOMEM; return -1; } return load_modules(moddir); }
static gboolean handle_enable_modules (StoragedManager *object, GDBusMethodInvocation *invocation, gboolean arg_enable) { StoragedLinuxManager *manager = STORAGED_LINUX_MANAGER (object); if (! arg_enable) { /* TODO: implement proper module unloading */ g_dbus_method_invocation_return_error_literal (invocation, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid value \"FALSE\""); return TRUE; } if (! storaged_daemon_get_disable_modules (manager->daemon)) load_modules (manager->daemon); storaged_manager_complete_enable_modules (object, invocation); return TRUE; /* returning TRUE means that we handled the method invocation */ }
void host_init(char *ifname) { struct sockaddr_in *ina; char buf[1024], tmp_ifname[IFNAMSIZ], ifnames[(IFNAMSIZ + 1) * MAX_NR_INTERFACES], *iface; struct ifconf ifc; struct ifreq ifreq, *ifr; int i, iw_sock, if_sock = 0; memset(&this_host, 0, sizeof(struct host_info)); memset(dev_indices, 0, sizeof(unsigned int) * MAX_NR_INTERFACES); if (!ifname) { /* No interface was given... search for first wireless. */ iw_sock = socket(PF_INET, SOCK_DGRAM, 0); ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if (ioctl(iw_sock, SIOCGIFCONF, &ifc) < 0) { fprintf(stderr, "Could not get wireless info\n"); exit(-1); } ifr = ifc.ifc_req; for (i = ifc.ifc_len / sizeof(struct ifreq); i >= 0; i--, ifr++) { struct iwreq req; strcpy(req.ifr_name, ifr->ifr_name); if (ioctl(iw_sock, SIOCGIWNAME, &req) >= 0) { strcpy(tmp_ifname, ifr->ifr_name); break; } } /* Did we find a wireless interface? */ if (!strlen(tmp_ifname)) { fprintf(stderr, "\nCould not find a wireless interface!\n"); fprintf(stderr, "Use -i <interface> to override...\n\n"); exit(-1); } strcpy(ifreq.ifr_name, tmp_ifname); if (ioctl(iw_sock, SIOCGIFINDEX, &ifreq) < 0) { alog(LOG_ERR, errno, __FUNCTION__, "Could not get index of %s", tmp_ifname); close(if_sock); exit(-1); } close(iw_sock); ifname = tmp_ifname; alog(LOG_NOTICE, 0, __FUNCTION__, "Attaching to %s, override with -i <if1,if2,...>.", tmp_ifname); } strcpy(ifnames, ifname); /* Intitialize the local sequence number an rreq_id to zero */ this_host.seqno = 1; this_host.rreq_id = 0; /* Zero interfaces enabled so far... */ this_host.nif = 0; gettimeofday(&this_host.bcast_time, NULL); /* Find the indices of all interfaces to broadcast on... */ if_sock = socket(AF_INET, SOCK_DGRAM, 0); iface = strtok(ifname, ","); /* OK, now lookup interface information, and store it... */ do { strcpy(ifreq.ifr_name, iface); if (ioctl(if_sock, SIOCGIFINDEX, &ifreq) < 0) { alog(LOG_ERR, errno, __FUNCTION__, "Could not get index of %s", iface); close(if_sock); exit(-1); } this_host.devs[this_host.nif].ifindex = ifreq.ifr_ifindex; dev_indices[this_host.nif++] = ifreq.ifr_ifindex; strcpy(DEV_IFINDEX(ifreq.ifr_ifindex).ifname, iface); /* Get IP-address of interface... */ ina = get_if_info(iface, SIOCGIFADDR); if (ina == NULL) exit(-1); DEV_IFINDEX(ifreq.ifr_ifindex).ipaddr = ina->sin_addr; /* Get netmask of interface... */ ina = get_if_info(iface, SIOCGIFNETMASK); if (ina == NULL) exit(-1); DEV_IFINDEX(ifreq.ifr_ifindex).netmask = ina->sin_addr; ina = get_if_info(iface, SIOCGIFBRDADDR); if (ina == NULL) exit(-1); DEV_IFINDEX(ifreq.ifr_ifindex).broadcast = ina->sin_addr; DEV_IFINDEX(ifreq.ifr_ifindex).enabled = 1; if (this_host.nif >= MAX_NR_INTERFACES) break; } while ((iface = strtok(NULL, ","))); close(if_sock); /* Load kernel modules */ load_modules(ifnames); /* Enable IP forwarding and set other kernel options... */ if (set_kernel_options() < 0) { fprintf(stderr, "Could not set kernel options!\n"); exit(-1); } }
int main(int argc, char **argv) { ZBX_TASK_EX t; #ifdef _WINDOWS int ret; /* Provide, so our process handles errors instead of the system itself. */ /* Attention!!! */ /* The system does not display the critical-error-handler message box. */ /* Instead, the system sends the error to the calling process.*/ SetErrorMode(SEM_FAILCRITICALERRORS); #endif #if defined(PS_OVERWRITE_ARGV) || defined(PS_PSTAT_ARGV) argv = setproctitle_save_env(argc, argv); #endif memset(&t, 0, sizeof(t)); t.task = ZBX_TASK_START; progname = get_program_name(argv[0]); parse_commandline(argc, argv, &t); import_symbols(); /* this is needed to set default hostname in zbx_load_config() */ init_metrics(); switch (t.task) { case ZBX_TASK_SHOW_USAGE: usage(); exit(EXIT_FAILURE); break; #ifdef _WINDOWS case ZBX_TASK_INSTALL_SERVICE: case ZBX_TASK_UNINSTALL_SERVICE: case ZBX_TASK_START_SERVICE: case ZBX_TASK_STOP_SERVICE: zbx_load_config(ZBX_CFG_FILE_REQUIRED); zbx_free_config(); if (t.flags & ZBX_TASK_FLAG_MULTIPLE_AGENTS) { zbx_snprintf(ZABBIX_SERVICE_NAME, sizeof(ZABBIX_SERVICE_NAME), "%s [%s]", APPLICATION_NAME, CONFIG_HOSTNAME); zbx_snprintf(ZABBIX_EVENT_SOURCE, sizeof(ZABBIX_EVENT_SOURCE), "%s [%s]", APPLICATION_NAME, CONFIG_HOSTNAME); } ret = zbx_exec_service_task(argv[0], &t); free_metrics(); exit(ret); break; #endif case ZBX_TASK_TEST_METRIC: case ZBX_TASK_PRINT_SUPPORTED: zbx_load_config(ZBX_CFG_FILE_OPTIONAL); #ifdef _WINDOWS init_perf_collector(0); load_perf_counters(CONFIG_PERF_COUNTERS); #else zbx_set_common_signal_handlers(); #endif #ifndef _WINDOWS if (FAIL == load_modules(CONFIG_LOAD_MODULE_PATH, CONFIG_LOAD_MODULE, CONFIG_TIMEOUT, 0)) { zabbix_log(LOG_LEVEL_CRIT, "loading modules failed, exiting..."); exit(EXIT_FAILURE); } #endif load_user_parameters(CONFIG_USER_PARAMETERS); load_aliases(CONFIG_ALIASES); zbx_free_config(); if (ZBX_TASK_TEST_METRIC == t.task) test_parameter(TEST_METRIC); else test_parameters(); #ifdef _WINDOWS free_perf_collector(); /* cpu_collector must be freed before perf_collector is freed */ #endif #ifndef _WINDOWS unload_modules(); #endif free_metrics(); alias_list_free(); exit(SUCCEED); break; default: zbx_load_config(ZBX_CFG_FILE_REQUIRED); break; } START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT); exit(SUCCEED); }
int MAIN_ZABBIX_ENTRY() { zbx_thread_args_t *thread_args; zbx_sock_t listen_sock; int i, thread_num = 0; #ifdef _WINDOWS DWORD res; #endif if (NULL == CONFIG_LOG_FILE || '\0' == *CONFIG_LOG_FILE) zabbix_open_log(LOG_TYPE_SYSLOG, CONFIG_LOG_LEVEL, NULL); else zabbix_open_log(LOG_TYPE_FILE, CONFIG_LOG_LEVEL, CONFIG_LOG_FILE); zabbix_log(LOG_LEVEL_INFORMATION, "Starting Zabbix Agent [%s]. Zabbix %s (revision %s).", CONFIG_HOSTNAME, ZABBIX_VERSION, ZABBIX_REVISION); zabbix_log(LOG_LEVEL_INFORMATION, "using configuration file: %s", CONFIG_FILE); #ifndef _WINDOWS if (FAIL == load_modules(CONFIG_LOAD_MODULE_PATH, CONFIG_LOAD_MODULE, CONFIG_TIMEOUT, 1)) { zabbix_log(LOG_LEVEL_CRIT, "loading modules failed, exiting..."); exit(EXIT_FAILURE); } #endif if (0 != CONFIG_PASSIVE_FORKS) { if (FAIL == zbx_tcp_listen(&listen_sock, CONFIG_LISTEN_IP, (unsigned short)CONFIG_LISTEN_PORT)) { zabbix_log(LOG_LEVEL_CRIT, "listener failed: %s", zbx_tcp_strerror()); exit(1); } } init_collector_data(); #ifdef _WINDOWS init_perf_collector(1); load_perf_counters(CONFIG_PERF_COUNTERS); #endif load_user_parameters(CONFIG_USER_PARAMETERS); load_aliases(CONFIG_ALIASES); zbx_free_config(); /* --- START THREADS ---*/ /* allocate memory for a collector, all listeners and an active check */ threads_num = 1 + CONFIG_PASSIVE_FORKS + CONFIG_ACTIVE_FORKS; threads = zbx_calloc(threads, threads_num, sizeof(ZBX_THREAD_HANDLE)); /* start the collector thread */ thread_args = (zbx_thread_args_t *)zbx_malloc(NULL, sizeof(zbx_thread_args_t)); thread_args->thread_num = thread_num; thread_args->thread_num2 = 1; thread_args->args = NULL; threads[thread_num++] = zbx_thread_start(collector_thread, thread_args); /* start listeners */ for (i = 0; i < CONFIG_PASSIVE_FORKS; i++) { thread_args = (zbx_thread_args_t *)zbx_malloc(NULL, sizeof(zbx_thread_args_t)); thread_args->thread_num = thread_num; thread_args->thread_num2 = i + 1; thread_args->args = &listen_sock; threads[thread_num++] = zbx_thread_start(listener_thread, thread_args); } /* start active check */ for (i = 0; i < CONFIG_ACTIVE_FORKS; i++) { thread_args = (zbx_thread_args_t *)zbx_malloc(NULL, sizeof(zbx_thread_args_t)); thread_args->thread_num = thread_num; thread_args->thread_num2 = i + 1; thread_args->args = &CONFIG_ACTIVE_ARGS[i]; threads[thread_num++] = zbx_thread_start(active_checks_thread, thread_args); } #ifdef _WINDOWS set_parent_signal_handler(); /* must be called after all threads are created */ /* wait for an exiting thread */ res = WaitForMultipleObjectsEx(threads_num, threads, FALSE, INFINITE, FALSE); if (ZBX_IS_RUNNING()) { /* Zabbix agent service should either be stopped by the user in ServiceCtrlHandler() or */ /* crash. If some thread has terminated normally, it means something is terribly wrong. */ zabbix_log(LOG_LEVEL_CRIT, "One thread has terminated unexpectedly (code:%lu). Exiting ...", res); THIS_SHOULD_NEVER_HAPPEN; /* notify other threads and allow them to terminate */ ZBX_DO_EXIT(); zbx_sleep(1); } else { /* wait for the service worker thread to terminate us */ zbx_sleep(3); THIS_SHOULD_NEVER_HAPPEN; } #else while (-1 == wait(&i)) /* wait for any child to exit */ { if (EINTR != errno) { zabbix_log(LOG_LEVEL_ERR, "failed to wait on child processes: %s", zbx_strerror(errno)); break; } } /* all exiting child processes should be caught by signal handlers */ THIS_SHOULD_NEVER_HAPPEN; #endif zbx_on_exit(); return SUCCEED; }
void host_init(char *ifname) { static struct local_host_info host_info; struct sockaddr_in *ina; char buf[1024]; struct ifconf ifc; struct ifreq *ifr; int i, iw_sock; /* Make sure the global "this_host" pointer points to the info structure so that the information can be accessed from outside this function... */ memset(&host_info, '\0', sizeof(struct local_host_info)); this_host = &host_info; /* Find the first wireless interface */ if(ifname != NULL) strcpy(host_info.ifname, ifname); else { iw_sock= socket(AF_INET, SOCK_DGRAM, 0); ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if(ioctl(iw_sock, SIOCGIFCONF, &ifc) < 0) { fprintf(stderr, "Could not get wireless info\n"); exit(-1); } ifr = ifc.ifc_req; for(i = ifc.ifc_len / sizeof(struct ifreq); i >= 0; i--, ifr++) { struct iwreq req; strcpy(req.ifr_name, ifr->ifr_name); if (ioctl(iw_sock, SIOCGIWNAME, &req) >= 0) { strcpy(host_info.ifname, ifr->ifr_name); break; } } close(iw_sock); /* Did we find a wireless interface? */ if(host_info.ifname[0] == '\0') { fprintf(stderr, "Could not find a wireless interface!\n"); fprintf(stderr, "Use -i <interface> to override...\n"); exit(-1); } } /* Load required kernel modules */ load_modules(host_info.ifname); /* Get IP-address of interface... */ ina = get_if_info(host_info.ifname, SIOCGIFADDR); if(ina == NULL) exit(-1); /* Remember our host IP address... */ host_info.ipaddr = ntohl(ina->sin_addr.s_addr); /* printf("Address of interface %s is %s\n", host_info.ifname, */ /* ip_to_str(host_info.ipaddr)); */ /* Get netmask of interface... */ ina = get_if_info(host_info.ifname, SIOCGIFNETMASK); if(ina == NULL) exit(-1); /* Remember the netmask */ host_info.netmask = ntohl(ina->sin_addr.s_addr); /* printf("Netmask of interface %s is %s\n", host_info.ifname, */ /* ip_to_str(host_info.netmask)); */ ina = get_if_info(host_info.ifname, SIOCGIFBRDADDR); if(ina == NULL) exit(-1); host_info.broadcast = ntohl(ina->sin_addr.s_addr); /* printf("Broadcast address is %s\n", ip_to_str(host_info.broadcast)); */ /* Enable IP forwarding and set other kernel options... */ if(set_kernel_options(host_info.ifname) < 0) { fprintf(stderr, "Could not set kernel options!\n"); exit(-1); } /* Add broadcast route (255.255.255.255) */ k_add_rte(AODV_BROADCAST, 0, 0, 0); /* Intitialize the local sequence number an flood_id to zero */ host_info.seqno = 0; host_info.flood_id = 0; }
/** * exit function if a signal is received in daemon mode. * * Argument: signal number * Return: None */ gboolean nuauth_reload(int signum) { struct nuauth_params *newconf = NULL; gboolean restart; int retval; g_message("[+] Reload NuAuth server"); nuauth_install_signals(FALSE); /* Reload the configuration file */ retval = nuauth_parse_configuration(nuauthconf->configfile); if (retval != 0) { log_message(CRITICAL, DEBUG_AREA_MAIN, "Cannot reload configuration (file '%s')", nuauthconf->configfile); return -1; } init_nuauthconf(&newconf); g_message("nuauth module reloading"); /* block threads of pool at start */ block_thread_pools(); /* we have to wait that all threads are blocked */ wait_all_thread_pools(); /* unload modules */ unload_modules(); /* Only duplicate configfile info, if configfile has not been set */ if (! newconf->configfile) { newconf->configfile = g_strdup(nuauthconf->configfile); } /* switch conf before loading modules */ restart = compare_nuauthparams(nuauthconf, newconf); if (restart == FALSE) { apply_new_config(newconf); /* debug is set via command line thus duplicate */ newconf->debug_level = nuauthconf->debug_level; free_nuauth_params(nuauthconf); g_free(nuauthconf); nuauthconf = newconf; } else { free_nuauth_params(newconf); } /* reload modules with new conf */ load_modules(); /* init period */ nuauthconf->periods = init_periods(nuauthconf); /* ask cache to reset */ if (nuauthconf->acl_cache) { cache_reset(nuauthdatas->acl_cache); } release_thread_pools(); nuauth_install_signals(TRUE); force_refresh_crl_file(); g_message("[+] NuAuth server reloaded"); return restart; }
/* * 处理主要游戏逻辑的逻辑服务器进程 */ int main(int argc , char **argv){ sspackage_t sspackage; char arg_segs[ARG_SEG_COUNT][ARG_CONTENT_LEN]; /*参数内容*/ online_players_t *ponline_players; /*保存在线玩家信息的结构,共享内存*/ runtime_env_t *pruntime_env; /*游戏运行时环境*/ int index; u64 ticks = 0; /*计时滴答*/ struct sigaction sig_act; /*信号动作*/ int iret; int icount; int i; module_commond_t module_commond; void *handle = NULL; /*动态加载模块句柄*/ /*检测参数*/ if(argc < 2){ write_log(LOG_ERR , "logic_server:argc < 2 , please input more information worldid.lineid.xxxx , like:1.1.xxxx"); return -1; } /*解析参数字符串*/ icount = strsplit(argv[1] , '.' , arg_segs , ARG_SEG_COUNT , ARG_CONTENT_LEN); if(icount < 2){ write_log(LOG_ERR , "logic_server:illegal argument 1:%s , exit!" , argv[1]); return -1; } world_id = atoi(arg_segs[0]); /*世界ID*/ line_id = atoi(arg_segs[1]); /*线ID*/ if(world_id<=0 || world_id>MAX_WORLD_COUNT || line_id<=0 || line_id>MAX_LINE_COUNT){ /*ID不能小于0或超出最大*/ write_log(LOG_ERR , "logic_server:illegal argument1:%s , exit!" , argv[1]); return -1; } #ifdef DEBUG printf("world_id:%d , line_id:%d\n" , world_id , line_id); #endif connect_server_id = GEN_WORLDID(world_id) | GEN_LINEID(line_id) | FLAG_SERV | GAME_CONNECT_SERVER; logic_server_id = GEN_WORLDID(world_id) | GEN_LINEID(line_id) | FLAG_SERV | GAME_LOGIC_SERVER; log_server_id = GEN_WORLDID(world_id) | GEN_LINEID(line_id) | FLAG_SERV | GAME_LOG_SERVER; /*注册信号*/ memset(&sig_act , 0 , sizeof(sig_act)); sig_act.sa_handler = handle_signal; sigaction(SIGINT , &sig_act , NULL); sigaction(SIGUSR1 , &sig_act , NULL); ctrl_msg = 0; /***链接BUS*/ iret = open_bus(connect_server_id , logic_server_id); if(iret < 0){ write_log(LOG_ERR , "logic_server:open bus connect <-> logic failed!"); return -1; } /***获得游戏运行时环境*/ pruntime_env = (runtime_env_t *)attach_shm_res(GAME_RT_ENV , world_id , line_id); if(!pruntime_env){ write_log(LOG_ERR , "logic_server:attach runtime env failed!"); return -1; }else{ write_log(LOG_INFO , "logic_server:attach runtime env %x success!" , pruntime_env->basic.global_id); } //设置相关信息 index = index_last_1bit(GAME_LOGIC_SERVER); pruntime_env->basic.proc_info[index].global_id = logic_server_id; pruntime_env->basic.proc_info[index].pid = getpid(); // printf("proc_t:%x vs pid:%d\n" , pruntime_env->basic.proc_info[index].global_id , pruntime_env->basic.proc_info[index].pid); /***链接在线玩家共享内存*/ ponline_players = (online_players_t *)attach_shm_res(GAME_ONLINE_PLAYERS , world_id , line_id); if(!ponline_players){ return -1; }else{ write_log(LOG_INFO , "logic_server:attach online_players %x success!" , ponline_players->global_id); } /***加载模块*/ iret = load_modules(MODULE_TYPE_CS , -1 , cs_module_starts , CS_PROTO_MODULE_COUNT); if(iret < 0) { return -1; } // cs_module1_start(CS , 1 , NULL); // cs_module2_start(1 , 1 , NULL); // cs_module3_start(1 , 1 , NULL); module_commond.type = MODULE_COMMOND_RELOAD; module_commond.data.pmodule_dir_path = "../XXMODULE/"; for(i=0; i<CS_PROTO_MODULE_COUNT; i++) { cs_module_starts[i](MODULE_TYPE_CS , NULL , &module_commond); } /***start success*/ write_log(LOG_INFO , "start logic_server %s success!" , argv[1]); /***主循环*/ while(1){ ticks++; /*循环一次加一次*/ /***读包*/ do{ iret = get_bus_pkg(logic_server_id , connect_server_id , &sspackage); if(iret == -1){ /*读包出错*/ write_log(LOG_ERR , "logic server: recv bus failed!"); break; } if(iret == -2){ /*BUS为空*/ break; } /*BUS有货*/ switch(sspackage.sshead.package_type){ case SS_FROM_CLIENT: handle_req_client(&sspackage); break; default: break; } }while(0); /***其他的定时处理机制*/ //检测是否存在控制信息 if(ticks % 5 == 0 && ctrl_msg){ handle_ctrl_msg(pruntime_env); } } /*end while*/ return 0; }
/* * This program should be used to parse the log file generated by FxT */ int main (int argc, char **argv) { int ret; int fd_in; load_modules(1); setTraceType (PAJE); /* parse the arguments passed to this program */ parse_args (argc, argv); #ifdef GTG_OUT_OF_ORDER ret = initTrace(output_filename, 0, GTG_FLAG_OUTOFORDER); #else ret = initTrace(output_filename, 0, GTG_FLAG_NONE); #endif if(ret != TRACE_SUCCESS) { fprintf(stderr, "fail to initialize GTG\n"); return 1; } if(compress) if(setCompress(9) != TRACE_SUCCESS) fprintf(stderr, "Fail to enable trace compression\n"); eztrace_initialize_gtg(); __init_modules(); int i; /* initialize the traces array */ for(i=0;i< NB_TRACES; i++) { /* open the trace file */ fxt_t fut = fxt_open (get_traces(i)->input_filename); if (!fut) { perror ("fxt_open:"); exit (-1); } get_traces(i)->delay = 0; get_traces(i)->rank = i; get_traces(i)->id = i; get_traces(i)->done = 0; get_traces(i)->skip = 0; get_traces(i)->line_number = 0; eztrace_create_containers(i); /* if several traces are loaded, this means that MPI was used, * so let's skip all the first events until MPI_Init is detected */ if(NB_TRACES > 1) { get_traces(i)->start = 0; get_traces(i)->trace_id = NULL; } else { CREATE_TRACE_ID_STR(get_traces(i)->trace_id, 0); get_traces(i)->start = 1; NB_START= 1; addContainer (0.00000, get_traces(i)->trace_id, "CT_Process", "C_Prog", get_traces(i)->trace_id, "0"); eztrace_create_ids(get_traces(i)->rank); } get_traces(i)->block = fxt_blockev_enter (fut); ret = fxt_next_ev (get_traces(i)->block, FXT_EV_TYPE_64, (struct fxt_ev *) &get_traces(i)->ev); if (ret != FXT_EV_OK) { fprintf (stderr, "no more block ...\n"); break; } get_traces(i)->start_time = get_traces(i)->ev.time; } /* todo: 0 or i ? */ set_cur_trace(get_traces(0)); set_cur_ev(&get_traces(i)->ev); struct eztrace_event_handler* h_info = NULL; h_info = get_handler_info(); h_info->cur_trace_nb = 0; h_info->nb_done = 0; h_info->nb_handled = 0; sem_init(&h_info->events_processed, 0, 0); /* create the handler thread and wait until it completes */ create_main_thread(); wake_up_handler_thread(); sem_wait(&h_info->events_processed); /* finalize the trace and close the file */ endTrace (); eztrace_convert_finalize(); printf("%d events handled\n", h_info->nb_handled); return 0; }
int MAIN_ZABBIX_ENTRY() { DB_RESULT result; DB_ROW row; pid_t pid; zbx_sock_t listen_sock; int i, server_num = 0, server_count = 0; if (NULL == CONFIG_LOG_FILE || '\0' == *CONFIG_LOG_FILE) zabbix_open_log(LOG_TYPE_SYSLOG, CONFIG_LOG_LEVEL, NULL); else zabbix_open_log(LOG_TYPE_FILE, CONFIG_LOG_LEVEL, CONFIG_LOG_FILE); #ifdef HAVE_SNMP # define SNMP_FEATURE_STATUS "YES" #else # define SNMP_FEATURE_STATUS " NO" #endif #ifdef HAVE_OPENIPMI # define IPMI_FEATURE_STATUS "YES" #else # define IPMI_FEATURE_STATUS " NO" #endif #ifdef HAVE_LIBCURL # define LIBCURL_FEATURE_STATUS "YES" #else # define LIBCURL_FEATURE_STATUS " NO" #endif #if defined(HAVE_LIBXML2) && defined(HAVE_LIBCURL) # define VMWARE_FEATURE_STATUS "YES" #else # define VMWARE_FEATURE_STATUS " NO" #endif #ifdef HAVE_JABBER # define JABBER_FEATURE_STATUS "YES" #else # define JABBER_FEATURE_STATUS " NO" #endif #ifdef HAVE_UNIXODBC # define ODBC_FEATURE_STATUS "YES" #else # define ODBC_FEATURE_STATUS " NO" #endif #ifdef HAVE_SSH2 # define SSH2_FEATURE_STATUS "YES" #else # define SSH2_FEATURE_STATUS " NO" #endif #ifdef HAVE_IPV6 # define IPV6_FEATURE_STATUS "YES" #else # define IPV6_FEATURE_STATUS " NO" #endif zabbix_log(LOG_LEVEL_INFORMATION, "Starting Zabbix Server. Zabbix %s (revision %s).", ZABBIX_VERSION, ZABBIX_REVISION); zabbix_log(LOG_LEVEL_INFORMATION, "****** Enabled features ******"); zabbix_log(LOG_LEVEL_INFORMATION, "SNMP monitoring: " SNMP_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "IPMI monitoring: " IPMI_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "WEB monitoring: " LIBCURL_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "VMware monitoring: " VMWARE_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "Jabber notifications: " JABBER_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "Ez Texting notifications: " LIBCURL_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "ODBC: " ODBC_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "SSH2 support: " SSH2_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "IPv6 support: " IPV6_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "******************************"); if (0 != CONFIG_NODEID) { zabbix_log(LOG_LEVEL_INFORMATION, "NodeID: %3d", CONFIG_NODEID); zabbix_log(LOG_LEVEL_INFORMATION, "******************************"); } zabbix_log(LOG_LEVEL_INFORMATION, "using configuration file: %s", CONFIG_FILE); if (FAIL == load_modules(CONFIG_LOAD_MODULE_PATH, CONFIG_LOAD_MODULE, CONFIG_TIMEOUT, 1)) { zabbix_log(LOG_LEVEL_CRIT, "loading modules failed, exiting..."); exit(EXIT_FAILURE); } zbx_free_config(); init_database_cache(); init_configuration_cache(); init_selfmon_collector(); /* initialize vmware support */ if (0 != CONFIG_VMWARE_FORKS) zbx_vmware_init(); /* initialize history value cache */ zbx_vc_init(); zbx_create_itservices_lock(); #ifdef HAVE_SQLITE3 zbx_create_sqlite3_mutex(); #endif if (SUCCEED != DBcheck_version()) exit(EXIT_FAILURE); DBconnect(ZBX_DB_CONNECT_NORMAL); if (0 != CONFIG_NODEID) { result = DBselect("select masterid from nodes where nodeid=%d", CONFIG_NODEID); if (NULL != (row = DBfetch(result)) && SUCCEED != DBis_null(row[0])) CONFIG_MASTER_NODEID = atoi(row[0]); DBfree_result(result); } DCload_config(); /* make initial configuration sync before worker processes are forked */ DCsync_configuration(); DBclose(); if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) { zbx_error("Unable to create mutex for node syncs"); exit(FAIL); } threads_num = CONFIG_CONFSYNCER_FORKS + CONFIG_WATCHDOG_FORKS + CONFIG_POLLER_FORKS + CONFIG_UNREACHABLE_POLLER_FORKS + CONFIG_TRAPPER_FORKS + CONFIG_PINGER_FORKS + CONFIG_ALERTER_FORKS + CONFIG_HOUSEKEEPER_FORKS + CONFIG_TIMER_FORKS + CONFIG_NODEWATCHER_FORKS + CONFIG_HTTPPOLLER_FORKS + CONFIG_DISCOVERER_FORKS + CONFIG_HISTSYNCER_FORKS + CONFIG_ESCALATOR_FORKS + CONFIG_IPMIPOLLER_FORKS + CONFIG_JAVAPOLLER_FORKS + CONFIG_SNMPTRAPPER_FORKS + CONFIG_PROXYPOLLER_FORKS + CONFIG_SELFMON_FORKS + CONFIG_VMWARE_FORKS; threads = zbx_calloc(threads, threads_num, sizeof(pid_t)); if (0 < CONFIG_TRAPPER_FORKS) { if (FAIL == zbx_tcp_listen(&listen_sock, CONFIG_LISTEN_IP, (unsigned short)CONFIG_LISTEN_PORT)) { zabbix_log(LOG_LEVEL_CRIT, "listener failed: %s", zbx_tcp_strerror()); exit(1); } } for (i = 0; i < threads_num; i++) { if (0 == (pid = zbx_child_fork())) { server_num = i + 1; /* child processes are numbered starting from 1 */ break; } else threads[i] = pid; } if (0 == server_num) { zabbix_log(LOG_LEVEL_INFORMATION, "server #0 started [main process]"); while (-1 == wait(&i)) /* wait for any child to exit */ { if (EINTR != errno) { zabbix_log(LOG_LEVEL_ERR, "failed to wait on child processes: %s", zbx_strerror(errno)); break; } } /* all exiting child processes should be caught by signal handlers */ THIS_SHOULD_NEVER_HAPPEN; zbx_on_exit(); } else if (server_num <= (server_count += CONFIG_CONFSYNCER_FORKS)) { /* !!! configuration syncer must be server #1 - child_signal_handler() uses threads[0] !!! */ INIT_SERVER(ZBX_PROCESS_TYPE_CONFSYNCER, CONFIG_CONFSYNCER_FORKS); main_dbconfig_loop(); } else if (server_num <= (server_count += CONFIG_WATCHDOG_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_WATCHDOG, CONFIG_WATCHDOG_FORKS); main_watchdog_loop(); } else if (server_num <= (server_count += CONFIG_POLLER_FORKS)) { #ifdef HAVE_SNMP init_snmp("zabbix_server"); #endif INIT_SERVER(ZBX_PROCESS_TYPE_POLLER, CONFIG_POLLER_FORKS); main_poller_loop(ZBX_POLLER_TYPE_NORMAL); } else if (server_num <= (server_count += CONFIG_UNREACHABLE_POLLER_FORKS)) { #ifdef HAVE_SNMP init_snmp("zabbix_server"); #endif INIT_SERVER(ZBX_PROCESS_TYPE_UNREACHABLE, CONFIG_UNREACHABLE_POLLER_FORKS); main_poller_loop(ZBX_POLLER_TYPE_UNREACHABLE); } else if (server_num <= (server_count += CONFIG_TRAPPER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_TRAPPER, CONFIG_TRAPPER_FORKS); main_trapper_loop(&listen_sock); } else if (server_num <= (server_count += CONFIG_PINGER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_PINGER, CONFIG_PINGER_FORKS); main_pinger_loop(); } else if (server_num <= (server_count += CONFIG_ALERTER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_ALERTER, CONFIG_ALERTER_FORKS); main_alerter_loop(); } else if (server_num <= (server_count += CONFIG_HOUSEKEEPER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_HOUSEKEEPER, CONFIG_HOUSEKEEPER_FORKS); main_housekeeper_loop(); } else if (server_num <= (server_count += CONFIG_TIMER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_TIMER, CONFIG_TIMER_FORKS); main_timer_loop(); } else if (server_num <= (server_count += CONFIG_NODEWATCHER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_NODEWATCHER, CONFIG_NODEWATCHER_FORKS); main_nodewatcher_loop(); } else if (server_num <= (server_count += CONFIG_HTTPPOLLER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_HTTPPOLLER, CONFIG_HTTPPOLLER_FORKS); main_httppoller_loop(); } else if (server_num <= (server_count += CONFIG_DISCOVERER_FORKS)) { #ifdef HAVE_SNMP init_snmp("zabbix_server"); #endif INIT_SERVER(ZBX_PROCESS_TYPE_DISCOVERER, CONFIG_DISCOVERER_FORKS); main_discoverer_loop(); } else if (server_num <= (server_count += CONFIG_HISTSYNCER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_HISTSYNCER, CONFIG_HISTSYNCER_FORKS); main_dbsyncer_loop(); } else if (server_num <= (server_count += CONFIG_ESCALATOR_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_ESCALATOR, CONFIG_ESCALATOR_FORKS); main_escalator_loop(); } else if (server_num <= (server_count += CONFIG_IPMIPOLLER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_IPMIPOLLER, CONFIG_IPMIPOLLER_FORKS); main_poller_loop(ZBX_POLLER_TYPE_IPMI); } else if (server_num <= (server_count += CONFIG_JAVAPOLLER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_JAVAPOLLER, CONFIG_JAVAPOLLER_FORKS); main_poller_loop(ZBX_POLLER_TYPE_JAVA); } else if (server_num <= (server_count += CONFIG_SNMPTRAPPER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_SNMPTRAPPER, CONFIG_SNMPTRAPPER_FORKS); main_snmptrapper_loop(); } else if (server_num <= (server_count += CONFIG_PROXYPOLLER_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_PROXYPOLLER, CONFIG_PROXYPOLLER_FORKS); main_proxypoller_loop(); } else if (server_num <= (server_count += CONFIG_SELFMON_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_SELFMON, CONFIG_SELFMON_FORKS); main_selfmon_loop(); } else if (server_num <= (server_count += CONFIG_VMWARE_FORKS)) { INIT_SERVER(ZBX_PROCESS_TYPE_VMWARE, CONFIG_VMWARE_FORKS); main_vmware_loop(); } return SUCCEED; }
/** * \brief Main program function * * This functions parse command line options to determine Isaac behaviour * This progran can be used as a Isaac process or a CLI client * if -r option is specified. * * \param argc Argument counter * \param argv Array of string arguments passed to the program */ int main(int argc, char *argv[]) { pid_t pid; int opt_remote = 0; char opt; char * xarg = NULL; // Parse commandline arguments while ((opt = getopt(argc, argv, "dhrvx:")) != EOF) { switch (opt) { case 'd': debug++; break; case 'r': opt_remote++; break; case 'x': opt_execute++; opt_remote++; // This is implicit in 'x' xarg = strdup(optarg); break; case 'v': version(); exit(EXIT_SUCCESS); case 'h': case '?': usage(); exit(EXIT_SUCCESS); } } // Check if there is an Isaac is already running if (opt_remote) { if (remote_tryconnect() == 0) { if (!opt_execute) { remote_control(NULL); return 0; } else { remote_control(xarg); return 0; } } else { fprintf(stderr, "Unable to connect to remote Isaac (does %s exist?)\n", CLI_SOCKET); exit(1); } } else { // Check Isaac is not already running if (access(CLI_SOCKET, F_OK) == 0) { fprintf(stderr, "%s already running on %s. Use '%s -r' to connect\n", argv[0], CLI_SOCKET, argv[0]); exit(1); } } // If we are not in debug mode, then fork to background if (!debug) { if ((pid = fork()) < 0) exit(1); else if (pid > 0) exit(0); } cfg_init(&config); // Setup signal handlers (void) signal(SIGINT, quit); (void) signal(SIGTERM, quit); (void) signal(SIGPIPE, SIG_IGN); // Read configuration files if (cfg_read(&config, CFILE) != 0) { fprintf(stderr, "Failed to read configuration file %s\n", CFILE); quit(EXIT_FAILURE); } // Initialize logging if (start_logging(config.logtype, config.logfile, config.logtag, config.loglevel) != 0) { fprintf(stderr, "Failed to read configuration file %s\n", CFILE); quit(EXIT_FAILURE); } // Load Modules. The contain the server Applications if (load_modules() != 0) { quit(EXIT_FAILURE); } // Start manager thread if (start_manager(config.manaddr, config.manport, config.manuser, config.manpass) != 0) { quit(EXIT_FAILURE); } // Start cli service if (cli_server_start() != 0) { quit(EXIT_FAILURE); } // Start server thread if (start_server(config.listenaddr, config.listenport) == -1) { quit(EXIT_FAILURE); } // All subsystems Up! isaac_log(LOG_NONE, "\e[1;37m%s Ready.\e[0m\n", PACKAGE_NAME); // Wait here until any signal is sent pause(); // Unreachable code :D return 0; }
int main(int argc, char **argv) { parse_config_file(DEFAULT_CONF_FILE_PATH); load_modules(); statis.cur_time = time(NULL); conf.print_day = -1; main_init(argc, argv); /* * enter running */ switch (conf.running_mode) { case RUN_LIST: running_list(); break; case RUN_CRON: conf.print_mode = DATA_DETAIL; running_cron(); break; #ifdef OLDTSAR /*for check option*/ case RUN_CHECK: reload_check_modules(); /* disable module when n_col is zero */ running_check(RUN_CHECK); break; /*end*/ #endif case RUN_CHECK_NEW: if (reload_modules(conf.output_print_mod)) { conf.print_mode = DATA_DETAIL; }; /* disable module when n_col is zero */ disable_col_zero(); running_check(RUN_CHECK_NEW); break; case RUN_PRINT: /* reload module by output_stdio_mod and output_print_mod*/ reload_modules(conf.output_stdio_mod); reload_modules(conf.output_print_mod); /* disable module when n_col is zero */ disable_col_zero(); /* set conf.print_nline_interval */ conf.print_nline_interval = conf.print_interval; running_print(); break; case RUN_PRINT_LIVE: /* reload module by output_stdio_mod and output_print_mod*/ reload_modules(conf.output_stdio_mod); reload_modules(conf.output_print_mod); /* disable module when n_col is zero */ disable_col_zero(); running_print_live(); break; default: break; } shut_down(); return 0; }
void plugin_factory_collection::load_modules(const std::string& Paths, const bool Recursive, const load_proxy_t LoadProxies) { const system::paths_t paths = system::decompose_path_list(Paths); for(system::paths_t::const_iterator path = paths.begin(); path != paths.end(); ++path) load_modules(*path, Recursive, LoadProxies); }
int main(int argc, char **argv) { char ch; int task = ZBX_TASK_START; char *TEST_METRIC = NULL; zbx_sock_t s_in; zbx_sock_t s_out; int ret; char **value; AGENT_RESULT result; progname = get_program_name(argv[0]); /* parse the command-line */ while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, "c:hVpt:", longopts, NULL))) { switch (ch) { case 'c': CONFIG_FILE = strdup(zbx_optarg); break; case 'h': help(); exit(EXIT_SUCCESS); break; case 'V': version(); #ifdef _AIX tl_version(); #endif exit(EXIT_SUCCESS); break; case 'p': if (task == ZBX_TASK_START) task = ZBX_TASK_PRINT_SUPPORTED; break; case 't': if (task == ZBX_TASK_START) { task = ZBX_TASK_TEST_METRIC; TEST_METRIC = strdup(zbx_optarg); } break; default: usage(); exit(EXIT_FAILURE); break; } } if (NULL == CONFIG_FILE) CONFIG_FILE = DEFAULT_CONFIG_FILE; /* load configuration */ if (ZBX_TASK_PRINT_SUPPORTED == task || ZBX_TASK_TEST_METRIC == task) zbx_load_config(ZBX_CFG_FILE_OPTIONAL); else zbx_load_config(ZBX_CFG_FILE_REQUIRED); /* set defaults */ if (NULL == CONFIG_LOAD_MODULE_PATH) CONFIG_LOAD_MODULE_PATH = zbx_strdup(CONFIG_LOAD_MODULE_PATH, LIBDIR "/modules"); zbx_set_common_signal_handlers(); /* metrics should be initialized before loading user parameters */ init_metrics(); /* loadable modules */ if (FAIL == load_modules(CONFIG_LOAD_MODULE_PATH, CONFIG_LOAD_MODULE, CONFIG_TIMEOUT, 0)) { zabbix_log(LOG_LEVEL_CRIT, "loading modules failed, exiting..."); exit(EXIT_FAILURE); } /* user parameters */ load_user_parameters(CONFIG_USER_PARAMETERS); /* aliases */ load_aliases(CONFIG_ALIASES); zbx_free_config(); /* do not create debug files */ zabbix_open_log(LOG_TYPE_SYSLOG, LOG_LEVEL_EMPTY, NULL); switch (task) { case ZBX_TASK_TEST_METRIC: case ZBX_TASK_PRINT_SUPPORTED: if (ZBX_TASK_TEST_METRIC == task) test_parameter(TEST_METRIC); else test_parameters(); zbx_on_exit(); break; default: /* do nothing */ break; } alarm(CONFIG_TIMEOUT); zbx_tcp_init(&s_in, (ZBX_SOCKET)fileno(stdin)); zbx_tcp_init(&s_out, (ZBX_SOCKET)fileno(stdout)); if (SUCCEED == (ret = zbx_tcp_check_security(&s_in, CONFIG_HOSTS_ALLOWED, 0))) { if (SUCCEED == (ret = zbx_tcp_recv(&s_in))) { zbx_rtrim(s_in.buffer, "\r\n"); zabbix_log(LOG_LEVEL_DEBUG, "requested [%s]", s_in.buffer); init_result(&result); process(s_in.buffer, 0, &result); if (NULL == (value = GET_TEXT_RESULT(&result))) value = GET_MSG_RESULT(&result); if (NULL != value) { zabbix_log(LOG_LEVEL_DEBUG, "sending back [%s]", *value); ret = zbx_tcp_send(&s_out, *value); } free_result(&result); } if (FAIL == ret) zabbix_log(LOG_LEVEL_DEBUG, "processing error: %s", zbx_tcp_strerror()); } fflush(stdout); alarm(0); zbx_on_exit(); return SUCCEED; }
static void* run_thread(void* arg) { mthread* thread = (mthread*) arg; PerlInterpreter* my_perl = construct_perl(); const message *to_run, *modules, *message; SV *call, *status; perl_mutex* shutdown_mutex; thread->interp = my_perl; #ifndef WIN32 S_set_sigmask(&thread->initial_sigmask); #endif PERL_SET_CONTEXT(my_perl); store_self(my_perl, thread); { dSP; modules = queue_dequeue(thread->queue, NULL); load_modules(my_perl, modules); to_run = queue_dequeue(thread->queue, NULL); ENTER; SAVETMPS; call = SvRV(message_load_value(to_run)); PUSHMARK(SP); mXPUSHs(newSVpvn("exit", 4)); status = newSVpvn("normal", 6); mXPUSHs(status); mXPUSHs(newSViv(thread->id)); ENTER; PUSHMARK(SP); PUTBACK; call_sv(call, G_SCALAR|G_EVAL); SPAGAIN; if (SvTRUE(ERRSV)) { sv_setpvn(status, "error", 5); warn("Thread %"UVuf" got error %s\n", thread->id, SvPV_nolen(ERRSV)); PUSHs(ERRSV); } message_from_stack_pushed(message); LEAVE; send_listeners(thread, message); destroy_message(message); FREETMPS; LEAVE; } shutdown_mutex = get_shutdown_mutex(); MUTEX_LOCK(shutdown_mutex); perl_destruct(my_perl); MUTEX_UNLOCK(shutdown_mutex); mthread_destroy(thread); PerlMemShared_free(thread); perl_free(my_perl); return NULL; }
void entry(struct Multiboot_Info_dec * old_mbinfo) { // This function is entered into by the kernel header // which sets up some basic tables for use and passes on // the multiboot info structure struct Multiboot_Info_dec mbinfo; #ifdef DEBUG U8 * screen = (U8 *)0xB8000; U16 i; // Clear the screen so debug messages are more visible for (i = 0; i < 160; i+=2) { screen[i] = ' '; screen[i+1] = 0x17; } for (i = 160; i < 7840; i+=2) { screen[i] = ' '; screen[i+1] = 0x07; } dprint("\t\t\tThe Poseidon Project Kernel.\n\n"); dprint("The Poseidon Project (c) Copyright 1998, 1999 John Barker\n"); dprint("All rights reserved. 32 bit message based real time operating system.\n\n"); #endif // Copy the old table to a local one for safe keeping // because once memory is initialized the old one may be wiped memcpy(&mbinfo,old_mbinfo,sizeof(struct Multiboot_Info_dec)); // Set up the exception traps init_traps(); // Allocate the irq routines init_irqs(); // Initialize memory management so we can use kmalloc and other // memory based functions init_mm(&mbinfo); // Initialize the object manager so we can start using it init_obj(); // Initialize the module/driver interface so modules can be loaded init_mdi(); // Set up the clocks and timers init_time(); // Set up tables and data for the executive init_executive(); // Initialize IPC and message buffers for all objects init_ipc(); // Initialize the system calls (system call interface) init_sci(); // Load all the modules passed to us at boot time, one of these // should be init or main load_modules(&mbinfo); // Start the executive scheduler, will boot the init module start_executive(); // The idle function - just loop, should be run in user mode idle(); }
extern "C" int main(stage2_args *args) { TRACE(("boot(): enter\n")); if (heap_init(args) < B_OK) panic("Could not initialize heap!\n"); TRACE(("boot(): heap initialized...\n")); // set debug syslog default #if KDEBUG_ENABLE_DEBUG_SYSLOG gKernelArgs.keep_debug_output_buffer = true; #endif add_stage2_driver_settings(args); platform_init_video(); // the main platform dependent initialisation // has already taken place at this point. if (vfs_init(args) < B_OK) panic("Could not initialize VFS!\n"); dprintf("Welcome to the Haiku boot loader!\n"); bool mountedAllVolumes = false; Directory *volume = get_boot_file_system(args); if (volume == NULL || (platform_boot_options() & BOOT_OPTION_MENU) != 0) { if (volume == NULL) puts("\tno boot path found, scan for all partitions...\n"); if (mount_file_systems(args) < B_OK) { // That's unfortunate, but we still give the user the possibility // to insert a CD-ROM or just rescan the available devices puts("Could not locate any supported boot devices!\n"); } // ToDo: check if there is only one bootable volume! mountedAllVolumes = true; if (user_menu(&volume) < B_OK) { // user requested to quit the loader goto out; } } if (volume != NULL) { // we got a volume to boot from! status_t status; while ((status = load_kernel(args, volume)) < B_OK) { // loading the kernel failed, so let the user choose another // volume to boot from until it works volume = NULL; if (!mountedAllVolumes) { // mount all other file systems, if not already happened if (mount_file_systems(args) < B_OK) panic("Could not locate any supported boot devices!\n"); mountedAllVolumes = true; } if (user_menu(&volume) < B_OK || volume == NULL) { // user requested to quit the loader goto out; } } // if everything is okay, continue booting; the kernel // is already loaded at this point and we definitely // know our boot volume, too if (status == B_OK) { register_boot_file_system(volume); if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) == 0) platform_switch_to_logo(); load_modules(args, volume); load_driver_settings(args, volume); // apply boot settings apply_boot_settings(); // set up kernel args version info gKernelArgs.kernel_args_size = sizeof(kernel_args); gKernelArgs.version = CURRENT_KERNEL_ARGS_VERSION; // clone the boot_volume KMessage into kernel accessible memory // note, that we need to 4 byte align the buffer and thus allocate // 3 more bytes void* buffer = kernel_args_malloc(gBootVolume.ContentSize() + 3); if (!buffer) { panic("Could not allocate memory for the boot volume kernel " "arguments"); } buffer = (void*)(((addr_t)buffer + 3) & ~(addr_t)0x3); memcpy(buffer, gBootVolume.Buffer(), gBootVolume.ContentSize()); gKernelArgs.boot_volume = buffer; gKernelArgs.boot_volume_size = gBootVolume.ContentSize(); // ToDo: cleanup, heap_release() etc. platform_start_kernel(); } } out: heap_release(args); return 0; }
int main(int argc, char *argv[]) { int ret, server_mode; void *host_addr = memalign(1024 * 1024, HOST_SIZE); msgType dialog_type; sys_ppu_thread_t id; // start server thread load_modules(); init_logging(); netInitialize(); netCtlInit(); // Initialize SPUs LOG(lm_main, LOG_DEBUG, ("Initializing SPUs\n")); ret = sysSpuInitialize(MAX_PHYSICAL_SPU, MAX_RAW_SPU); if (ret != 0) { LOG(lm_main, LOG_ERROR, ("sysSpuInitialize failed: %d\n", ret)); goto quit; } init_screen(host_addr, HOST_SIZE); ioPadInit(7); ret = initialize_exit_handlers(); if (ret != 0) goto quit; show_version(); if (user_requested_exit()) goto quit; u64 CEX=0x4345580000000000ULL; u64 DEX=0x4445580000000000ULL; u64 DEH=0x4445480000000000ULL; if(lv2peek(0x80000000002E79C8ULL)==DEX) {dex_mode=2; c_firmware=3.41f;} else if(lv2peek(0x80000000002CFF98ULL)==CEX) {dex_mode=0; c_firmware=3.41f;} else if(lv2peek(0x80000000002EFE20ULL)==DEX) {dex_mode=2; c_firmware=3.55f;} else if(lv2peek(0x80000000002D83D0ULL)==CEX) {dex_mode=0; c_firmware=3.55f;} else if(lv2peek(0x8000000000302D88ULL)==DEX) {dex_mode=2; c_firmware=4.21f;} else if(lv2peek(0x80000000002E8610ULL)==CEX) {dex_mode=0; c_firmware=4.21f;} else if(lv2peek(0x80000000002E9F08ULL)==CEX) {dex_mode=0; c_firmware=4.30f;} else if(lv2peek(0x8000000000304630ULL)==DEX) {dex_mode=2; c_firmware=4.30f;} else if(lv2peek(0x80000000002E9F18ULL)==CEX) {dex_mode=0; c_firmware=4.31f;} else if(lv2peek(0x80000000002EA488ULL)==CEX) {dex_mode=0; c_firmware=4.40f;} else if(lv2peek(0x80000000002EA498ULL)==CEX) {dex_mode=0; c_firmware=4.41f;} else if(lv2peek(0x8000000000304EF0ULL)==DEX) {dex_mode=2; c_firmware=4.41f;} else if(lv2peek(0x80000000002EA9B8ULL)==CEX) {dex_mode=0; c_firmware=4.46f;} else if(lv2peek(0x8000000000305410ULL)==DEX) {dex_mode=2; c_firmware=4.46f;} else if(lv2peek(0x80000000002E9BE0ULL)==CEX) {dex_mode=0; c_firmware=4.50f;} else if(lv2peek(0x8000000000309698ULL)==DEX) {dex_mode=2; c_firmware=4.50f;} else if(lv2peek(0x80000000002E9D70ULL)==CEX) {dex_mode=0; c_firmware=4.53f;} else if(lv2peek(0x80000000002EC5E0ULL)==CEX) {dex_mode=0; c_firmware=4.55f;} else if(lv2peek(0x80000000002ED850ULL)==CEX) {dex_mode=0; c_firmware=4.60f;} else if(lv2peek(0x80000000002ED860ULL)==CEX) {dex_mode=0; c_firmware=4.65f;} else if(lv2peek(0x800000000030F1A8ULL)==DEX) {dex_mode=2; c_firmware=4.65f;} else if(lv2peek(0x80000000002ED778ULL)==CEX) {dex_mode=0; c_firmware=4.70f;} else if(lv2peek(0x800000000030F240ULL)==DEX) {dex_mode=2; c_firmware=4.70f;} else if(lv2peek(0x80000000002ED818ULL)==CEX) {dex_mode=0; c_firmware=4.75f;} else if(lv2peek(0x800000000030F2D0ULL)==DEX) {dex_mode=2; c_firmware=4.75f;} else if(lv2peek(0x80000000002ED808ULL)==CEX) {dex_mode=0; c_firmware=4.80f;} else if(lv2peek(0x800000000030F3A0ULL)==DEX) {dex_mode=2; c_firmware=4.80f;} else if(lv2peek(0x800000000030F3B0ULL)==DEX) {dex_mode=2; c_firmware=4.81f;} else if(lv2peek(0x800000000032EB60ULL)==DEH) {deh_mode=2; c_firmware=4.81f;} else c_firmware=0.00f; if(c_firmware==3.55f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_355D; } else if(c_firmware==3.55f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_355; } else if(c_firmware==4.21f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_421; } else if(c_firmware==4.30f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_430; } else if(c_firmware==4.30f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_430D; } else if(c_firmware==4.31f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_431; } else if(c_firmware==4.40f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_440; } else if(c_firmware==4.41f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_441; } else if(c_firmware==4.41f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_441D; } else if(c_firmware==4.46f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_446; } else if(c_firmware==4.50f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_450; } else if(c_firmware==4.53f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_453; } else if(c_firmware==4.55f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_455; } else if(c_firmware==4.60f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_460; } else if(c_firmware==4.65f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_465; } else if(c_firmware==4.65f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_465D; } else if(c_firmware==4.70f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_470; } else if(c_firmware==4.70f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_470D; } else if(c_firmware==4.75f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_475; } else if(c_firmware==4.80f && !dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_480; } else if(c_firmware==4.80f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_480D; } else if(c_firmware==4.75f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_475D; } else if(c_firmware==4.81f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_481D; } else if(c_firmware==4.46f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_446D; } else if(c_firmware==4.50f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_450D; } else if(c_firmware==4.21f && dex_mode) { SYSCALL_TABLE = SYSCALL_TABLE_421D; } else if(c_firmware==3.41f) { SYSCALL_TABLE = SYSCALL_TABLE_341; } else if(c_firmware==4.81f && deh_mode) { SYSCALL_TABLE = SYSCALL_TABLE_481H; } /* if(c_firmware>=4.20f && SYSCALL_TABLE) { // add and enable lv2 peek/poke + lv1 peek/poke lv2poke(0x800000000000171CULL, 0x7C0802A6F8010010ULL); lv2poke(0x800000000000171CULL + 8, 0x396000B644000022ULL); lv2poke(0x800000000000171CULL + 16, 0x7C832378E8010010ULL); lv2poke(0x800000000000171CULL + 24, 0x7C0803A64E800020ULL); lv2poke(0x800000000000171CULL + 32, 0x7C0802A6F8010010ULL); lv2poke(0x800000000000171CULL + 40, 0x396000B744000022ULL); lv2poke(0x800000000000171CULL + 48, 0x38600000E8010010ULL); lv2poke(0x800000000000171CULL + 56, 0x7C0803A64E800020ULL); lv2poke(0x800000000000171CULL + 64, 0x7C0802A6F8010010ULL); lv2poke(0x800000000000171CULL + 72, 0x7D4B537844000022ULL); lv2poke(0x800000000000171CULL + 80, 0xE80100107C0803A6ULL); lv2poke(0x800000000000171CULL + 88, 0x4E80002080000000ULL); lv2poke(0x800000000000171CULL + 96, 0x0000170C80000000ULL); lv2poke(0x800000000000171CULL + 104, 0x0000171480000000ULL); lv2poke(0x800000000000171CULL + 112, 0x0000171C80000000ULL); lv2poke(0x800000000000171CULL + 120, 0x0000173C80000000ULL); lv2poke(0x800000000000171CULL + 128, 0x0000175C00000000ULL); lv2poke(SYSCALL_PTR( 6), 0x8000000000001778ULL); //sc6 lv2poke(SYSCALL_PTR( 7), 0x8000000000001780ULL); //sc7 lv2poke(SYSCALL_PTR( 8), 0x8000000000001788ULL); //sc8 lv2poke(SYSCALL_PTR( 9), 0x8000000000001790ULL); //sc9 lv2poke(SYSCALL_PTR(10), 0x8000000000001798ULL); //sc10 }*/ // remove patch protection if(c_firmware==3.55f) remove_protection(); if(c_firmware==0.00f) ret = -1; else ret = patch_lv1_ss_services(); if (ret < 0) { dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON); msgDialogOpen2(dialog_type, "ERROR: Couldn't patch lv1 services, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL); dialog_action = 0; while (!dialog_action && !user_requested_exit()) { sysUtilCheckCallback(); flip(); } msgDialogAbort(); goto quit; } // patch syscall 864 to allow drive re-init if(c_firmware==0.0f) ret = -1; else ret = patch_syscall_864(); if (ret < 0) { dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON); msgDialogOpen2(dialog_type, "ERROR: Couldn't patch syscall 864, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL); dialog_action = 0; while (!dialog_action && !user_requested_exit()) { sysUtilCheckCallback(); flip(); } msgDialogAbort(); goto quit; } // install the necessary modules ret = install_modules(); if (ret < 0) { dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON); msgDialogOpen2(dialog_type, "Installation was aborted, returning to the XMB.", dialog_handler, NULL, NULL); dialog_action = 0; while (!dialog_action && !user_requested_exit()) { sysUtilCheckCallback(); flip(); } msgDialogAbort(); goto quit; } if (user_requested_exit()) goto quit; // reset & re-authenticate the BD drive sys_storage_reset_bd(); sys_storage_authenticate_bd(); // eject current disc { int fd; ret = sys_storage_open(BD_DEVICE, &fd); if (ret == 0) { ioctl_eject(fd); sys_storage_close(fd); } } ret = sysDiscRegisterDiscChangeCallback(&bd_eject_disc_callback, &bd_insert_disc_callback); // poll for an output_device poll_output_devices(); server_mode = user_select_server_mode(); if (user_requested_exit()) goto quit; if (server_mode) { #ifdef ENABLE_LOGGING if (output_device) { char file_path[100]; sprintf(file_path, "%s/daemon_log.txt", output_device); set_log_file(file_path); } #endif sysThreadCreate(&id, listener_thread, NULL, 1500, 0x400, 0, "listener"); while (1) { // server loop server_loop(); // break out of the loop when requested if (user_requested_exit()) break; } } else { while (1) { // main loop main_loop(); // break out of the loop when requested if (user_requested_exit()) break; } } ret = sysDiscUnregisterDiscChangeCallback(); quit: unpatch_lv1_ss_services(); destroy_logging(); netDeinitialize(); unload_modules(); free(host_addr); return 0; }
/** * Initialize all data: * - Create different queues: * - tls_push_queue: read in push_worker() ; * - connections_queue: read in search_and_fill() ; * - localid_auth_queue: read in localid_auth(). * - Create hash table ::conn_list * - Init. modules: init_modules_system(), load_modules() * - Init. periods: init_periods() * - Init. cache: init_acl_cache() and init_user_cache() (if enabled) * - Create thread pools: * - ip_authentication_workers with external_ip_auth() (if enabled) ; * - acl_checkers with acl_check_and_decide() ; * - user_loggers with real_log_user_packet() ; * - user_session_loggers with log_user_session_thread() ; * - decisions_workers with decisions_queue_work(). * - Create threads: * - tls_pusher with push_worker() ; * - search_and_fill_worker with search_and_fill() ; * - localid_auth_thread with localid_auth() (if needed) ; * - tls_auth_servers with tls_user_start_servers() ; * - tls_nufw_servers with tls_nufw_start_servers() ; * - limited_connections_handler with limited_connection_handler(). * * Other queue, threads, etc. are created elsewhere: * - in tls_user_init(): tls_sasl_worker thread pool, tls_sasl_connect(). */ void init_nuauthdata() { block_thread_pools(); nuauthdatas->tls_push_queue = g_async_queue_new(); if (!nuauthdatas->tls_push_queue) exit(EXIT_FAILURE); /* initialize packets list */ conn_list = g_hash_table_new_full((GHashFunc) hash_connection, (GEqualFunc) tracking_equal, NULL, (GDestroyNotify) free_connection); /* async queue initialisation */ nuauthdatas->connections_queue = g_async_queue_new(); if (!nuauthdatas->connections_queue) exit(EXIT_FAILURE); init_protocol_extension(nuauthdatas); /* init and load modules */ init_modules_system(); if (!load_modules()) exit(EXIT_FAILURE); /* init periods */ nuauthconf->periods = init_periods(nuauthconf); if (nuauthconf->acl_cache) init_acl_cache(); /* create user cache thread */ if (nuauthconf->user_cache) init_user_cache(); start_all_thread_pools(); null_message = g_new0(struct cache_message, 1); null_queue_datas = g_new0(gchar, 1); /* init private datas for pool thread */ nuauthdatas->aclqueue = g_private_new((GDestroyNotify) g_async_queue_unref); nuauthdatas->userqueue = g_private_new((GDestroyNotify) g_async_queue_unref); g_static_mutex_init(&insert_mutex); /* create thread for search_and_fill thread */ log_message(VERBOSE_DEBUG, DEBUG_AREA_MAIN, "Creating search_and_fill thread"); thread_new(&nuauthdatas->search_and_fill_worker, "search&fill", search_and_fill); if (nuauthconf->push && nuauthconf->hello_authentication) { log_message(VERBOSE_DEBUG, DEBUG_AREA_MAIN, "Creating hello mode authentication thread"); nuauthdatas->localid_auth_queue = g_async_queue_new(); thread_new(&nuauthdatas->localid_auth_thread, "localid", localid_auth); } #ifdef BUILD_NUAUTH_COMMAND if (nuauthconf->use_command_server) { log_message(VERBOSE_DEBUG, DEBUG_AREA_MAIN, "Creating command thread"); thread_new(&nuauthdatas->command_thread, "command", command_server); } #endif /* create thread for client request sender */ thread_new(&nuauthdatas->tls_pusher, "tls pusher", push_worker); /* create TLS authentication server threads (auth + nufw) */ tls_common_init(); log_message(VERBOSE_DEBUG, DEBUG_AREA_MAIN, "Creating tls authentication server threads"); tls_user_start_servers(nuauthdatas->tls_auth_servers); log_message(VERBOSE_DEBUG, DEBUG_AREA_MAIN, "Creating tls nufw server threads"); tls_nufw_start_servers(nuauthdatas->tls_nufw_servers); log_message(INFO, DEBUG_AREA_MAIN, "Threads system started"); release_thread_pools(); nuauthdatas->is_starting = FALSE; }
int MAIN_ZABBIX_ENTRY() { zbx_sock_t listen_sock; int i, db_type; if (NULL == CONFIG_LOG_FILE || '\0' == *CONFIG_LOG_FILE) zabbix_open_log(LOG_TYPE_SYSLOG, CONFIG_LOG_LEVEL, NULL); else zabbix_open_log(LOG_TYPE_FILE, CONFIG_LOG_LEVEL, CONFIG_LOG_FILE); #ifdef HAVE_NETSNMP # define SNMP_FEATURE_STATUS "YES" #else # define SNMP_FEATURE_STATUS " NO" #endif #ifdef HAVE_OPENIPMI # define IPMI_FEATURE_STATUS "YES" #else # define IPMI_FEATURE_STATUS " NO" #endif #ifdef HAVE_LIBCURL # define LIBCURL_FEATURE_STATUS "YES" #else # define LIBCURL_FEATURE_STATUS " NO" #endif #if defined(HAVE_LIBXML2) && defined(HAVE_LIBCURL) # define VMWARE_FEATURE_STATUS "YES" #else # define VMWARE_FEATURE_STATUS " NO" #endif #ifdef HAVE_UNIXODBC # define ODBC_FEATURE_STATUS "YES" #else # define ODBC_FEATURE_STATUS " NO" #endif #ifdef HAVE_SSH2 # define SSH2_FEATURE_STATUS "YES" #else # define SSH2_FEATURE_STATUS " NO" #endif #ifdef HAVE_IPV6 # define IPV6_FEATURE_STATUS "YES" #else # define IPV6_FEATURE_STATUS " NO" #endif zabbix_log(LOG_LEVEL_INFORMATION, "Starting Zabbix Proxy (%s) [%s]. Zabbix %s (revision %s).", ZBX_PROXYMODE_PASSIVE == CONFIG_PROXYMODE ? "passive" : "active", CONFIG_HOSTNAME, ZABBIX_VERSION, ZABBIX_REVISION); zabbix_log(LOG_LEVEL_INFORMATION, "**** Enabled features ****"); zabbix_log(LOG_LEVEL_INFORMATION, "SNMP monitoring: " SNMP_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "IPMI monitoring: " IPMI_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "WEB monitoring: " LIBCURL_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "VMware monitoring: " VMWARE_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "ODBC: " ODBC_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "SSH2 support: " SSH2_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "IPv6 support: " IPV6_FEATURE_STATUS); zabbix_log(LOG_LEVEL_INFORMATION, "**************************"); zabbix_log(LOG_LEVEL_INFORMATION, "using configuration file: %s", CONFIG_FILE); if (FAIL == load_modules(CONFIG_LOAD_MODULE_PATH, CONFIG_LOAD_MODULE, CONFIG_TIMEOUT, 1)) { zabbix_log(LOG_LEVEL_CRIT, "loading modules failed, exiting..."); exit(EXIT_FAILURE); } zbx_free_config(); init_database_cache(); init_configuration_cache(); init_selfmon_collector(); /* initialize vmware support */ if (0 != CONFIG_VMWARE_FORKS) zbx_vmware_init(); DBinit(); if (ZBX_DB_UNKNOWN == (db_type = zbx_db_get_database_type())) { zabbix_log(LOG_LEVEL_ERR, "cannot use database \"%s\": database is not a Zabbix database", CONFIG_DBNAME); exit(EXIT_FAILURE); } else if (ZBX_DB_PROXY != db_type) { zabbix_log(LOG_LEVEL_ERR, "cannot use database \"%s\": Zabbix proxy cannot work with a" " Zabbix server database", CONFIG_DBNAME); exit(EXIT_FAILURE); } if (SUCCEED != DBcheck_version()) exit(EXIT_FAILURE); DBconnect(ZBX_DB_CONNECT_NORMAL); DCsync_configuration(); DBclose(); threads_num = CONFIG_CONFSYNCER_FORKS + CONFIG_HEARTBEAT_FORKS + CONFIG_DATASENDER_FORKS + CONFIG_POLLER_FORKS + CONFIG_UNREACHABLE_POLLER_FORKS + CONFIG_TRAPPER_FORKS + CONFIG_PINGER_FORKS + CONFIG_HOUSEKEEPER_FORKS + CONFIG_HTTPPOLLER_FORKS + CONFIG_DISCOVERER_FORKS + CONFIG_HISTSYNCER_FORKS + CONFIG_IPMIPOLLER_FORKS + CONFIG_JAVAPOLLER_FORKS + CONFIG_SNMPTRAPPER_FORKS + CONFIG_SELFMON_FORKS + CONFIG_VMWARE_FORKS; threads = zbx_calloc(threads, threads_num, sizeof(pid_t)); if (0 != CONFIG_TRAPPER_FORKS) { if (FAIL == zbx_tcp_listen(&listen_sock, CONFIG_LISTEN_IP, (unsigned short)CONFIG_LISTEN_PORT)) { zabbix_log(LOG_LEVEL_CRIT, "listener failed: %s", zbx_tcp_strerror()); exit(EXIT_FAILURE); } } zabbix_log(LOG_LEVEL_INFORMATION, "proxy #0 started [main process]"); for (i = 0; i < threads_num; i++) { zbx_thread_args_t thread_args; unsigned char poller_type; if (FAIL == get_process_info_by_thread(i + 1, &thread_args.process_type, &thread_args.process_num)) { THIS_SHOULD_NEVER_HAPPEN; exit(EXIT_FAILURE); } thread_args.server_num = i + 1; thread_args.args = NULL; switch (thread_args.process_type) { case ZBX_PROCESS_TYPE_CONFSYNCER: threads[i] = zbx_thread_start(proxyconfig_thread, &thread_args); break; case ZBX_PROCESS_TYPE_HEARTBEAT: threads[i] = zbx_thread_start(heart_thread, &thread_args); break; case ZBX_PROCESS_TYPE_DATASENDER: threads[i] = zbx_thread_start(datasender_thread, &thread_args); break; case ZBX_PROCESS_TYPE_POLLER: poller_type = ZBX_PROCESS_TYPE_POLLER; thread_args.args = &poller_type; threads[i] = zbx_thread_start(poller_thread, &thread_args); break; case ZBX_PROCESS_TYPE_UNREACHABLE: poller_type = ZBX_PROCESS_TYPE_UNREACHABLE; thread_args.args = &poller_type; threads[i] = zbx_thread_start(poller_thread, &thread_args); break; case ZBX_PROCESS_TYPE_TRAPPER: thread_args.args = &listen_sock; threads[i] = zbx_thread_start(trapper_thread, &thread_args); break; case ZBX_PROCESS_TYPE_PINGER: threads[i] = zbx_thread_start(pinger_thread, &thread_args); break; case ZBX_PROCESS_TYPE_HOUSEKEEPER: threads[i] = zbx_thread_start(housekeeper_thread, &thread_args); break; case ZBX_PROCESS_TYPE_HTTPPOLLER: threads[i] = zbx_thread_start(httppoller_thread, &thread_args); break; case ZBX_PROCESS_TYPE_DISCOVERER: threads[i] = zbx_thread_start(discoverer_thread, &thread_args); break; case ZBX_PROCESS_TYPE_HISTSYNCER: threads[i] = zbx_thread_start(dbsyncer_thread, &thread_args); break; case ZBX_PROCESS_TYPE_IPMIPOLLER: poller_type = ZBX_PROCESS_TYPE_IPMIPOLLER; thread_args.args = &poller_type; threads[i] = zbx_thread_start(poller_thread, &thread_args); break; case ZBX_PROCESS_TYPE_JAVAPOLLER: poller_type = ZBX_PROCESS_TYPE_JAVAPOLLER; thread_args.args = &poller_type; threads[i] = zbx_thread_start(poller_thread, &thread_args); break; case ZBX_PROCESS_TYPE_SNMPTRAPPER: threads[i] = zbx_thread_start(snmptrapper_thread, &thread_args); break; case ZBX_PROCESS_TYPE_SELFMON: threads[i] = zbx_thread_start(selfmon_thread, &thread_args); break; case ZBX_PROCESS_TYPE_VMWARE: threads[i] = zbx_thread_start(vmware_thread, &thread_args); break; } } while (-1 == wait(&i)) /* wait for any child to exit */ { if (EINTR != errno) { zabbix_log(LOG_LEVEL_ERR, "failed to wait on child processes: %s", zbx_strerror(errno)); break; } } /* all exiting child processes should be caught by signal handlers */ THIS_SHOULD_NEVER_HAPPEN; zbx_on_exit(); return SUCCEED; }