Commit 13f97cbc authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

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.
parent 8e1d9773
......@@ -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);
}
}
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment