move self_path to the base sigar_t
This commit is contained in:
		
							parent
							
								
									9166277502
								
							
						
					
					
						commit
						dc3eceb517
					
				@ -36,7 +36,8 @@
 | 
				
			|||||||
   sigar_pid_t pid; \
 | 
					   sigar_pid_t pid; \
 | 
				
			||||||
   char errbuf[256]; \
 | 
					   char errbuf[256]; \
 | 
				
			||||||
   char *ifconf_buf; \
 | 
					   char *ifconf_buf; \
 | 
				
			||||||
   int ifconf_len
 | 
					   int ifconf_len; \
 | 
				
			||||||
 | 
					   char *self_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(WIN32)
 | 
					#if defined(WIN32)
 | 
				
			||||||
#   define SIGAR_INLINE __inline
 | 
					#   define SIGAR_INLINE __inline
 | 
				
			||||||
 | 
				
			|||||||
@ -164,8 +164,6 @@ int sigar_os_open(sigar_t **sigar)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    (*sigar)->model[0] = '\0';
 | 
					    (*sigar)->model[0] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    (*sigar)->self_path[0] = '\0';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    uname(&name);
 | 
					    uname(&name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    (*sigar)->aix_version = atoi(name.version);
 | 
					    (*sigar)->aix_version = atoi(name.version);
 | 
				
			||||||
@ -231,7 +229,7 @@ static int proc_module_get_self(void *data, char *name, int len)
 | 
				
			|||||||
    if (strnEQ(ptr+1, "libsigar-", 9)) {
 | 
					    if (strnEQ(ptr+1, "libsigar-", 9)) {
 | 
				
			||||||
        *ptr = '\0'; /* chop libsigar-powerpc-ibm-aix-4.3.x.so */
 | 
					        *ptr = '\0'; /* chop libsigar-powerpc-ibm-aix-4.3.x.so */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SIGAR_SSTRCPY(sigar->self_path, name);
 | 
					        sigar->self_path = sigar_strdup(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (SIGAR_LOG_IS_DEBUG(sigar)) {
 | 
					        if (SIGAR_LOG_IS_DEBUG(sigar)) {
 | 
				
			||||||
            sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
 | 
					            sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
 | 
				
			||||||
@ -247,7 +245,7 @@ static int proc_module_get_self(void *data, char *name, int len)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static char *sigar_get_self_path(sigar_t *sigar)
 | 
					static char *sigar_get_self_path(sigar_t *sigar)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (sigar->self_path[0] == '\0') {
 | 
					    if (!sigar->self_path) {
 | 
				
			||||||
        sigar_proc_modules_t procmods;
 | 
					        sigar_proc_modules_t procmods;
 | 
				
			||||||
        procmods.module_getter = proc_module_get_self;
 | 
					        procmods.module_getter = proc_module_get_self;
 | 
				
			||||||
        procmods.data = sigar;
 | 
					        procmods.data = sigar;
 | 
				
			||||||
@ -255,9 +253,9 @@ static char *sigar_get_self_path(sigar_t *sigar)
 | 
				
			|||||||
        sigar_proc_modules_get(sigar, sigar_pid_get(sigar),
 | 
					        sigar_proc_modules_get(sigar, sigar_pid_get(sigar),
 | 
				
			||||||
                               &procmods);
 | 
					                               &procmods);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (sigar->self_path[0] == '\0') {
 | 
					        if (!sigar->self_path) {
 | 
				
			||||||
            /* dont try again */
 | 
					            /* dont try again */
 | 
				
			||||||
            SIGAR_SSTRCPY(sigar->self_path, ".");
 | 
					            sigar->self_path = sigar_strdup(".");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,6 @@ struct sigar_t {
 | 
				
			|||||||
    int cpuinfo_size;
 | 
					    int cpuinfo_size;
 | 
				
			||||||
    int cpu_mhz;
 | 
					    int cpu_mhz;
 | 
				
			||||||
    char model[128];
 | 
					    char model[128];
 | 
				
			||||||
    char self_path[SIGAR_PATH_MAX]; /* path to where libsigar.so lives */
 | 
					 | 
				
			||||||
    int aix_version;
 | 
					    int aix_version;
 | 
				
			||||||
    int thrusage;
 | 
					    int thrusage;
 | 
				
			||||||
    sigar_cache_t *diskmap; 
 | 
					    sigar_cache_t *diskmap; 
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@ SIGAR_DECLARE(int) sigar_open(sigar_t **sigar)
 | 
				
			|||||||
        (*sigar)->log_level = -1; /* log nothing by default */
 | 
					        (*sigar)->log_level = -1; /* log nothing by default */
 | 
				
			||||||
        (*sigar)->log_impl = NULL;
 | 
					        (*sigar)->log_impl = NULL;
 | 
				
			||||||
        (*sigar)->log_data = NULL;
 | 
					        (*sigar)->log_data = NULL;
 | 
				
			||||||
 | 
					        (*sigar)->self_path = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return status;
 | 
					    return status;
 | 
				
			||||||
@ -31,7 +32,9 @@ SIGAR_DECLARE(int) sigar_close(sigar_t *sigar)
 | 
				
			|||||||
    if (sigar->ifconf_buf) {
 | 
					    if (sigar->ifconf_buf) {
 | 
				
			||||||
        free(sigar->ifconf_buf);
 | 
					        free(sigar->ifconf_buf);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    if (sigar->self_path) {
 | 
				
			||||||
 | 
					        free(sigar->self_path);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return sigar_os_close(sigar);
 | 
					    return sigar_os_close(sigar);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user