static PgBackendStatus *BackendStatusArray = NULL;
static PgBackendStatus *MyBEEntry = NULL;
-static char *BackendClientHostnameBuffer = NULL;
static char *BackendAppnameBuffer = NULL;
+static char *BackendClientHostnameBuffer = NULL;
static char *BackendActivityBuffer = NULL;
static Size BackendActivityBufferSize = 0;
#ifdef USE_SSL
{
Size size;
+ /* BackendStatusArray: */
size = mul_size(sizeof(PgBackendStatus), MaxBackends);
+ /* BackendAppnameBuffer: */
+ size = add_size(size,
+ mul_size(NAMEDATALEN, MaxBackends));
+ /* BackendClientHostnameBuffer: */
size = add_size(size,
mul_size(NAMEDATALEN, MaxBackends));
+ /* BackendActivityBuffer: */
size = add_size(size,
mul_size(pgstat_track_activity_query_size, MaxBackends));
+#ifdef USE_SSL
+ /* BackendSslStatusBuffer: */
size = add_size(size,
- mul_size(NAMEDATALEN, MaxBackends));
+ mul_size(sizeof(PgBackendSSLStatus), MaxBackends));
+#endif
return size;
}
}
}
-#ifdef USE_SSL
- /* Create or attach to the shared SSL status buffer */
- size = mul_size(sizeof(PgBackendSSLStatus), MaxBackends);
- BackendSslStatusBuffer = (PgBackendSSLStatus *)
- ShmemInitStruct("Backend SSL Status Buffer", size, &found);
-
- if (!found)
- {
- MemSet(BackendSslStatusBuffer, 0, size);
-
- /* Initialize st_sslstatus pointers. */
- buffer = (char *) BackendSslStatusBuffer;
- for (i = 0; i < MaxBackends; i++)
- {
- BackendStatusArray[i].st_sslstatus = (PgBackendSSLStatus *) buffer;
- buffer += sizeof(PgBackendSSLStatus);
- }
- }
-#endif
-
/* Create or attach to the shared activity buffer */
BackendActivityBufferSize = mul_size(pgstat_track_activity_query_size,
MaxBackends);
buffer += pgstat_track_activity_query_size;
}
}
+
+#ifdef USE_SSL
+ /* Create or attach to the shared SSL status buffer */
+ size = mul_size(sizeof(PgBackendSSLStatus), MaxBackends);
+ BackendSslStatusBuffer = (PgBackendSSLStatus *)
+ ShmemInitStruct("Backend SSL Status Buffer", size, &found);
+
+ if (!found)
+ {
+ PgBackendSSLStatus *ptr;
+
+ MemSet(BackendSslStatusBuffer, 0, size);
+
+ /* Initialize st_sslstatus pointers. */
+ ptr = BackendSslStatusBuffer;
+ for (i = 0; i < MaxBackends; i++)
+ {
+ BackendStatusArray[i].st_sslstatus = ptr;
+ ptr++;
+ }
+ }
+#endif
}
volatile PgBackendStatus *beentry;
LocalPgBackendStatus *localtable;
LocalPgBackendStatus *localentry;
+ char *localappname,
+ *localactivity;
#ifdef USE_SSL
PgBackendSSLStatus *localsslstatus;
#endif
- char *localappname,
- *localactivity;
int i;
Assert(!pgStatRunningInCollector);
localappname = (char *)
MemoryContextAlloc(pgStatLocalContext,
NAMEDATALEN * MaxBackends);
+ localactivity = (char *)
+ MemoryContextAlloc(pgStatLocalContext,
+ pgstat_track_activity_query_size * MaxBackends);
#ifdef USE_SSL
localsslstatus = (PgBackendSSLStatus *)
MemoryContextAlloc(pgStatLocalContext,
sizeof(PgBackendSSLStatus) * MaxBackends);
#endif
- localactivity = (char *)
- MemoryContextAlloc(pgStatLocalContext,
- pgstat_track_activity_query_size * MaxBackends);
localNumBackends = 0;
beentry = BackendStatusArray;