aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2020-02-16 00:01:38 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-05-07 14:57:22 +0200
commit13f97cbc84c5fcc92cc7a82e79ddcb84d85c61ff (patch)
tree7fb3eaeb6f426ff699be3b843005ee37f20a3a9f /nx-X11/programs/Xserver
parent8e1d97732bc889659209406e99360972e2efb73d (diff)
downloadnx-libs-13f97cbc84c5fcc92cc7a82e79ddcb84d85c61ff.tar.gz
nx-libs-13f97cbc84c5fcc92cc7a82e79ddcb84d85c61ff.tar.bz2
nx-libs-13f97cbc84c5fcc92cc7a82e79ddcb84d85c61ff.zip
Client.c: add clientInfoString to client privates
This is a string that contains the address, the index, the PID and the process name of the client. The string can be used in debugging messages to identify the client.
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Client.c47
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Client.h5
2 files changed, 51 insertions, 1 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c
index 9b0f2c5e6..83554e573 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Client.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c
@@ -113,6 +113,14 @@ int nxagentClientPrivateIndex;
int nxagentShadowCounter = 0;
/*
+ * For the serverclient the ClientStateCallback will not be called on
+ * shutdown resulting in memory allocated during initClientPrivates can
+ * not be freed automatically. So instead of allocating some memory we
+ * create a static string for the serverclient.
+ */
+static char *serverclientInfoString = "[0] (serverclient)";
+
+/*
* called whenever the client state changes. See dixstruct.h for a
* list of known states.
*/
@@ -182,6 +190,42 @@ static void initClientPrivates(ClientPtr client)
nxagentClientPriv(client) -> clientBytes = 0;
#endif
nxagentClientPriv(client) -> clientHint = UNKNOWN;
+ nxagentClientPriv(client) -> clientInfoString = NULL;
+
+ char *s = NULL;
+ int size = 0;
+
+ if (client->index == 0)
+ {
+ s = serverclientInfoString;
+ }
+ else
+ {
+#ifdef CLIENTIDS
+ size = asprintf(&s, "[%d] (addr [%p] PID [%d] Cmd [%s])",
+ client->index, (void *)client,
+ GetClientPid(client),
+ GetClientCmdName(client));
+#else
+ size = asprintf(&s, "[%d] (addr [%p])",
+ client->index, (void *)client);
+#endif
+ }
+
+ if (size != -1)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "%s: clientInfoString: \"%s\"\n", __func__, s);
+ #endif
+
+ nxagentClientPriv(client) -> clientInfoString = s;
+ }
+ else
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "%s: could not alloc clientInfoString\n", __func__);
+ #endif
+ }
}
}
@@ -198,6 +242,9 @@ static void freeClientPrivates(ClientPtr client)
nxagentClientPriv(client) -> clientBytes = 0;
#endif
nxagentClientPriv(client) -> clientHint = UNKNOWN;
+
+ if (client->index != 0)
+ SAFE_free(nxagentClientPriv(client) -> clientInfoString);
}
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.h b/nx-X11/programs/Xserver/hw/nxagent/Client.h
index 38a02aed1..a3e6e3cf3 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Client.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Client.h
@@ -49,7 +49,7 @@ typedef struct _PrivClientRec
int clientState;
long clientBytes;
enum ClientHint clientHint;
-
+ char *clientInfoString;
} PrivClientRec;
extern int nxagentClientPrivateIndex;
@@ -75,6 +75,9 @@ extern void nxagentClientStateCallback(CallbackListPtr *callbacks, void *data, v
#define nxagentClientIsDialog(pClient) \
(nxagentClientHint(pClient) == NXCLIENT_DIALOG)
+#define nxagentClientInfoString(pClient) \
+ (nxagentClientPriv(pClient) -> clientInfoString)
+
/*
* The actual reason why the client is sleeping.
*/