From: Florian G. <re...@us...> - 2007-12-18 15:08:52
|
Update of /cvsroot/perfparse/_perfparse/perfparse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26895/perfparse Modified Files: perfparsed.c storage.c Log Message: added version information to storage module api and renamed upcoming version. Index: perfparsed.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/perfparse/perfparsed.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** perfparsed.c 18 Dec 2007 00:15:00 -0000 1.11 --- perfparsed.c 18 Dec 2007 15:08:51 -0000 1.12 *************** *** 63,79 **** if (pid < 0) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("daemonize failed (fork problem : errno=%d msg=%s)"),errno,strerror(errno)); exit(EXIT_FAILURE); } if (pid > 0) { ! pp_log(__FILE__,__LINE__,LOG_DEBUG,_("daemonize: fork succeeded. Parent process exiting\n")); exit (EXIT_SUCCESS); } ! pp_log(__FILE__,__LINE__,LOG_DEBUG,_("daemonize: fork succeeded. Child process PID: %d\n"),getpid()); sid=setsid (); if(sid<0) { ! pp_log(__FILE__,__LINE__,LOG_FATAL,_("daemonize: problem creating a new session for daemon process\n")); exit(EXIT_FAILURE); } --- 63,79 ---- if (pid < 0) { ! pp_log_fl(LOG_ERROR, _("daemonize failed (fork problem : errno=%d msg=%s)"),errno,strerror(errno)); exit(EXIT_FAILURE); } if (pid > 0) { ! pp_log_fl(LOG_DEBUG,_("daemonize: fork succeeded. Parent process exiting\n")); exit (EXIT_SUCCESS); } ! pp_log_fl(LOG_DEBUG,_("daemonize: fork succeeded. Child process PID: %d\n"),getpid()); sid=setsid (); if(sid<0) { ! pp_log_fl(LOG_FATAL,_("daemonize: problem creating a new session for daemon process\n")); exit(EXIT_FAILURE); } *************** *** 88,92 **** umask (022); if(0 != chdir (LOCALSTATEDIR)) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("daemonize failed (could not chdir('%s') : errno=%d msg=%s)"),LOCALSTATEDIR, errno,strerror(errno)); exit(EXIT_FAILURE); } --- 88,92 ---- umask (022); if(0 != chdir (LOCALSTATEDIR)) { ! pp_log_fl(LOG_ERROR, _("daemonize failed (could not chdir('%s') : errno=%d msg=%s)"),LOCALSTATEDIR, errno,strerror(errno)); exit(EXIT_FAILURE); } *************** *** 94,98 **** fd = open (lock_file, O_RDWR | O_CREAT, 0640); if (fd < 0) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("daemonize: cannot create lockfile %s\n"),lock_file); exit (EXIT_FAILURE); } --- 94,98 ---- fd = open (lock_file, O_RDWR | O_CREAT, 0640); if (fd < 0) { ! pp_log_fl(LOG_ERROR,_("daemonize: cannot create lockfile %s\n"),lock_file); exit (EXIT_FAILURE); } *************** *** 108,115 **** pid = strtol(tmp,NULL,10); if((0 == pid) && (EINVAL == errno)) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("File '%s' is corrupted"),lock_file); exit (EXIT_FAILURE); } ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("Perfparsed already running with PID %d"),pid); exit (EXIT_SUCCESS); } --- 108,115 ---- pid = strtol(tmp,NULL,10); if((0 == pid) && (EINVAL == errno)) { ! pp_log_fl(LOG_ERROR, _("File '%s' is corrupted"),lock_file); exit (EXIT_FAILURE); } ! pp_log_fl(LOG_ERROR, _("Perfparsed already running with PID %d"),pid); exit (EXIT_SUCCESS); } *************** *** 167,175 **** if(!strcmp(config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG),"-")) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Stdin not authorized as the perf data input source")); exit(EXIT_FAILURE); } if(config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG)[0] == '>') { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Client socket not authorized as the perf data input source")); exit(EXIT_FAILURE); } --- 167,175 ---- if(!strcmp(config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG),"-")) { ! pp_log_fl(LOG_ERROR,_("Stdin not authorized as the perf data input source")); exit(EXIT_FAILURE); } if(config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG)[0] == '>') { ! pp_log_fl(LOG_ERROR,_("Client socket not authorized as the perf data input source")); exit(EXIT_FAILURE); } *************** *** 178,187 **** if(config_get_value_as_boolean(CONFIG_ITEM_ID_DAEMONIZE) && (config_option == CONFIG_OPTION_NONE)) { daemonize(config_get_value_as_string(CONFIG_ITEM_ID_DAEMON_LOCK)); ! pp_log(__FILE__,__LINE__,LOG_INFO, _("Perfparsed successfully daemonized (pid=%ld)"),getpid()); } // load staorage modules if(0 == storage_init(NULL)) { ! pp_log(__FILE__,__LINE__,LOG_WARNING,_("No module was loaded. Check the Storage_Modules_Load config option.")); exit(EXIT_FAILURE); } --- 178,187 ---- if(config_get_value_as_boolean(CONFIG_ITEM_ID_DAEMONIZE) && (config_option == CONFIG_OPTION_NONE)) { daemonize(config_get_value_as_string(CONFIG_ITEM_ID_DAEMON_LOCK)); ! pp_log_fl(LOG_INFO, _("Perfparsed successfully daemonized (pid=%ld)"),getpid()); } // load staorage modules if(0 == storage_init(NULL)) { ! pp_log_fl(LOG_WARNING,_("No module was loaded. Check the Storage_Modules_Load config option.")); exit(EXIT_FAILURE); } *************** *** 205,213 **** service_log_source = config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG); if(service_log_source[0] && (0 > (open_log_source(service_log_source)))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Could not open log source ('%s') configured in Service_Log"),service_log_source); exit(EXIT_FAILURE); } if((config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT) > 0) && (0 > log_source_new_server(config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT)))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Could not create perfparse server\n")); exit(EXIT_FAILURE); } --- 205,213 ---- service_log_source = config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG); if(service_log_source[0] && (0 > (open_log_source(service_log_source)))) { ! pp_log_fl(LOG_ERROR,_("Could not open log source ('%s') configured in Service_Log"),service_log_source); exit(EXIT_FAILURE); } if((config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT) > 0) && (0 > log_source_new_server(config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT)))) { ! pp_log_fl(LOG_ERROR,_("Could not create perfparse server\n")); exit(EXIT_FAILURE); } *************** *** 250,254 **** break; default : ! pp_log(__FILE__,__LINE__,LOG_FATAL,_("This is a bug. This code should never be executed")); } } --- 250,254 ---- break; default : ! pp_log_fl(LOG_FATAL,_("This is a bug. This code should never be executed")); } } *************** *** 258,262 **** while(0 < waitpid(-1,NULL,WNOHANG)); } ! pp_log(__FILE__,__LINE__,LOG_FATAL,_("This is a bug. This code should never be executed")); close_all_log_sources(); log_reader_remove_signal_handler(); --- 258,262 ---- while(0 < waitpid(-1,NULL,WNOHANG)); } ! pp_log_fl(LOG_FATAL,_("This is a bug. This code should never be executed")); close_all_log_sources(); log_reader_remove_signal_handler(); Index: storage.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/perfparse/storage.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** storage.c 14 Dec 2007 21:42:17 -0000 1.8 --- storage.c 18 Dec 2007 15:08:51 -0000 1.9 *************** *** 57,72 **** char*libpath; storage_module_t *(*storage_module_init_cb)(void); void*storage_module_handle; libpath = g_strdup_printf("%s/libpp_storage_%s." SHLIBEXT,config_get_value_as_string(CONFIG_ITEM_ID_STORAGE_MODULES_DIR),storage_name); if(NULL == (storage_module_handle = dlopen(libpath, RTLD_LAZY))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("storage_%s module failed to load (msg='%s')\n"),storage_name, dlerror()); exit(EXIT_FAILURE); } g_free(libpath); storage_module_init_cb = dlsym(storage_module_handle, "storage_module_init"); if(NULL == storage_module_init_cb) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("storage_%s module failed to initialize\n"),storage_name); exit(EXIT_FAILURE); } --- 57,86 ---- char*libpath; storage_module_t *(*storage_module_init_cb)(void); + int (*storage_module_api_ver_cb) (void); void*storage_module_handle; libpath = g_strdup_printf("%s/libpp_storage_%s." SHLIBEXT,config_get_value_as_string(CONFIG_ITEM_ID_STORAGE_MODULES_DIR),storage_name); if(NULL == (storage_module_handle = dlopen(libpath, RTLD_LAZY))) { ! pp_log_fl(LOG_ERROR, _("storage_%s module failed to load (msg='%s')\n"),storage_name, dlerror()); exit(EXIT_FAILURE); } g_free(libpath); + storage_module_api_ver_cb = dlsym(storage_module_handle, "storage_module_api_version"); + if(storage_module_api_ver_cb == NULL) { + pp_log_fl(LOG_ERROR, _("storage_%s module does not have proper version information\n")); + exit(EXIT_FAILURE); + } + + if(storage_module_api_ver_cb()!=STORAGE_MODULE_API_VERSION) { + pp_log_fl(LOG_ERROR, _("storage_%s module is API version %d. Desired API version is %d.\n"), + storage_module_api_ver_cb(),STORAGE_MODULE_API_VERSION); + exit(EXIT_FAILURE); + } + + storage_module_init_cb = dlsym(storage_module_handle, "storage_module_init"); if(NULL == storage_module_init_cb) { ! pp_log_fl(LOG_ERROR, _("storage_%s module failed to initialize\n"),storage_name); exit(EXIT_FAILURE); } *************** *** 74,78 **** sm_new = storage_module_init_cb(); if(NULL == sm_new) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("storage_%s module failed to initialize itself\n"),storage_name); exit(EXIT_FAILURE); } --- 88,92 ---- sm_new = storage_module_init_cb(); if(NULL == sm_new) { ! pp_log_fl(LOG_ERROR, _("storage_%s module failed to initialize itself\n"),storage_name); exit(EXIT_FAILURE); } *************** *** 80,84 **** if(NULL == (sme=malloc(sizeof(storage_module_element_t)))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("Not enough memory (malloc failed)\n")); exit(EXIT_FAILURE); } --- 94,98 ---- if(NULL == (sme=malloc(sizeof(storage_module_element_t)))) { ! pp_log_fl(LOG_ERROR, _("Not enough memory (malloc failed)\n")); exit(EXIT_FAILURE); } *************** *** 95,102 **** storage_modules->prev = NULL; } ! pp_log(__FILE__,__LINE__,LOG_INFO, _("storage_%s module successfully loaded\n"),storage_name); } int storage_init(const char*argv0) { const char*b; char*modules_list; --- 109,117 ---- storage_modules->prev = NULL; } ! pp_log_fl(LOG_INFO, _("storage_%s module successfully loaded\n"),storage_name); } int storage_init(const char*argv0) { + pp_log_func; const char*b; char*modules_list; |