diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-11-01 01:09:51 +0100 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2020-11-02 22:15:01 +0100 |
commit | 45869513bfebba80cc2ab42e4218f68b34b1e6ac (patch) | |
tree | f064631dbff141bf1c945db8cff40b7bb82fd169 /solaris | |
parent | 61e14d4bb25268593019e6df3eb02264b4ac8e0e (diff) |
Embracing branches
Diffstat (limited to 'solaris')
-rw-r--r-- | solaris/Platform.c | 25 | ||||
-rw-r--r-- | solaris/SolarisProcessList.c | 27 |
2 files changed, 37 insertions, 15 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c index 69777726..6159c357 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -156,13 +156,19 @@ int Platform_getMaxPid() { kvar_t* ksvar = NULL; int vproc = 32778; // Reasonable Solaris default kc = kstat_open(); - if (kc != NULL) { kshandle = kstat_lookup(kc,"unix",0,"var"); } - if (kshandle != NULL) { kstat_read(kc,kshandle,NULL); } + if (kc != NULL) { + kshandle = kstat_lookup(kc, "unix", 0, "var"); + } + if (kshandle != NULL) { + kstat_read(kc, kshandle, NULL); + } ksvar = kshandle->ks_data; if (ksvar->v_proc > 0 ) { vproc = ksvar->v_proc; } - if (kc != NULL) { kstat_close(kc); } + if (kc != NULL) { + kstat_close(kc); + } return vproc; } @@ -195,7 +201,9 @@ double Platform_setCPUValues(Meter* this, int cpu) { } percent = CLAMP(percent, 0.0, 100.0); - if (isnan(percent)) percent = 0.0; + if (isnan(percent)) { + percent = 0.0; + } v[CPU_METER_FREQUENCY] = NAN; @@ -233,10 +241,12 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr (void) Phandle; (void) addr; size_t thissz = strlen(str); - if ((thissz + 2) > (accump->capacity - accump->size)) + if ((thissz + 2) > (accump->capacity - accump->size)) { accump->env = xRealloc(accump->env, accump->capacity *= 2); - if ((thissz + 2) > (accump->capacity - accump->size)) + } + if ((thissz + 2) > (accump->capacity - accump->size)) { return 1; + } strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size)); strncpy( accump->env + accump->size + thissz + 1, "\n", 1); accump->size = accump->size + thissz + 1; @@ -249,8 +259,9 @@ char* Platform_getProcessEnv(pid_t pid) { int graberr; struct ps_prochandle* Phandle; - if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) + if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) { return "Unable to read process environment."; + } envBuilder.capacity = 4096; envBuilder.size = 0; diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 31507506..49aeb24c 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -169,10 +169,11 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { pages = kstat_data_lookup(meminfo, "pagestotal"); pl->totalMem = totalmem_pgs->value.ui64 * CRT_pageSizeKB; - if (pl->totalMem > freemem_pgs->value.ui64 * CRT_pageSizeKB) + if (pl->totalMem > freemem_pgs->value.ui64 * CRT_pageSizeKB) { pl->usedMem = pl->totalMem - freemem_pgs->value.ui64 * CRT_pageSizeKB; - else - pl->usedMem = 0; // This can happen in non-global zone (in theory) + } else { + pl->usedMem = 0; // This can happen in non-global zone (in theory) + } // Not sure how to implement this on Solaris - suggestions welcome! pl->cachedMem = 0; // Not really "buffers" but the best Solaris analogue that I can find to @@ -268,7 +269,9 @@ void ProcessList_delete(ProcessList* pl) { SolarisProcessList* spl = (SolarisProcessList*) pl; ProcessList_done(pl); free(spl->cpus); - if (spl->kd) kstat_close(spl->kd); + if (spl->kd) { + kstat_close(spl->kd); + } free(spl); } @@ -287,7 +290,10 @@ int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* SolarisProcessList* spl = (SolarisProcessList*) listptr; id_t lwpid_real = _lwpsinfo->pr_lwpid; - if (lwpid_real > 1023) return 0; + if (lwpid_real > 1023) { + return 0; + } + pid_t lwpid = (_psinfo->pr_pid * 1024) + lwpid_real; bool onMasterLWP = (_lwpsinfo->pr_lwpid == _psinfo->pr_lwp.pr_lwpid); if (onMasterLWP) { @@ -347,9 +353,13 @@ int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* if (sproc->kernel && !pl->settings->hideKernelThreads) { pl->kernelThreads += proc->nlwp; pl->totalTasks += proc->nlwp + 1; - if (proc->state == 'O') pl->runningTasks++; + if (proc->state == 'O') { + pl->runningTasks++; + } } else if (!sproc->kernel) { - if (proc->state == 'O') pl->runningTasks++; + if (proc->state == 'O') { + pl->runningTasks++; + } if (pl->settings->hideUserlandThreads) { pl->totalTasks++; } else { @@ -403,8 +413,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { SolarisProcessList_scanZfsArcstats(super); // in pause mode only gather global data for meters (CPU/memory/...) - if (pauseProcessUpdate) + if (pauseProcessUpdate) { return; + } super->kernelThreads = 1; proc_walk(&SolarisProcessList_walkproc, super, PR_WALK_LWP); |