added level arg to client_stat

This commit is contained in:
Jeff Hill
1996-09-04 21:58:27 +00:00
parent 5b546d2467
commit 7fabc325bb
5 changed files with 115 additions and 107 deletions

View File

@@ -199,12 +199,12 @@ struct client *client,
struct message_buffer *recv
)
{
int nmsg = 0;
int nmsg = 0;
int v41;
unsigned msgsize;
unsigned bytes_left;
unsigned long msgsize;
unsigned long bytes_left;
int status;
caHdr *mp;
caHdr *mp;
struct channel_in_use *pciu;
if(!pCaBucket){
@@ -215,7 +215,7 @@ struct message_buffer *recv
}
if (CASDEBUG > 2){
logMsg( "CAS: Parsing %d(decimal) bytes\n",
logMsg( "CAS: Parsing %lu (decimal) bytes\n",
recv->cnt,
NULL,
NULL,
@@ -1823,8 +1823,8 @@ char *pformat,
*/
reply = (caHdr *) ALLOC_MSG(client, 512);
if (!reply){
int logMsgArgs[6];
int i;
int logMsgArgs[6];
unsigned i;
for(i=0; i< NELEMENTS(logMsgArgs); i++){
logMsgArgs[i] = va_arg(args, int);

View File

@@ -270,14 +270,14 @@ FAST int sock;
return ERROR;
}
client->recv.cnt = 0;
client->recv.cnt = 0ul;
while (TRUE) {
client->recv.stk = 0;
nchars = recv(
sock,
&client->recv.buf[client->recv.cnt],
sizeof(client->recv.buf)-client->recv.cnt,
(int)(sizeof(client->recv.buf)-client->recv.cnt),
0);
if (nchars==0){
if(CASDEBUG>0){
@@ -318,21 +318,21 @@ FAST int sock;
}
client->ticks_at_last_recv = tickGet();
client->recv.cnt += nchars;
client->recv.cnt += (unsigned long) nchars;
status = camessage(client, &client->recv);
if(status == OK){
unsigned bytes_left;
bytes_left = client->recv.cnt - client->recv.stk;
/*
* if there is a partial message
* align it with the start of the buffer
*/
if(bytes_left>0){
if(client->recv.cnt >= client->recv.stk){
unsigned bytes_left;
char *pbuf;
bytes_left = client->recv.cnt - client->recv.stk;
pbuf = client->recv.buf;
/*
@@ -345,10 +345,10 @@ FAST int sock;
client->recv.cnt = bytes_left;
}
else{
client->recv.cnt = 0;
client->recv.cnt = 0ul;
}
}else{
client->recv.cnt = 0;
client->recv.cnt = 0ul;
/*
* disconnect on message alignment
* problems
@@ -359,7 +359,7 @@ FAST int sock;
/*
* allow message to batch up if more are comming
*/
status = ioctl(sock, FIONREAD, (int)&nchars);
status = ioctl(sock, FIONREAD, &nchars);
if (status < 0) {
logMsg("CAS: io ctl err %d\n",
errnoGet(),

View File

@@ -69,7 +69,7 @@ static char *sccsId = "@(#) $Id$";
#include <server.h>
LOCAL int terminate_one_client(struct client *client);
LOCAL void log_one_client(struct client *client);
LOCAL void log_one_client(struct client *client, unsigned level);
LOCAL unsigned long delay_in_ticks(unsigned long prev);
@@ -427,7 +427,7 @@ LOCAL int terminate_one_client(struct client *client)
* client_stat()
*
*/
int client_stat(void)
int client_stat (unsigned level)
{
int bytes_reserved;
struct client *client;
@@ -440,37 +440,40 @@ int client_stat(void)
client = (struct client *) ellNext(&clientQ);
while (client) {
log_one_client(client);
log_one_client(client, level);
client = (struct client *) ellNext(&client->node);
}
UNLOCK_CLIENTQ;
if(prsrv_cast_client)
log_one_client(prsrv_cast_client);
bytes_reserved = 0;
bytes_reserved += sizeof(struct client)*
ellCount(&rsrv_free_clientQ);
bytes_reserved += sizeof(struct channel_in_use)*
ellCount(&rsrv_free_addrq);
bytes_reserved += (sizeof(struct event_ext)+db_sizeof_event_block())*
ellCount(&rsrv_free_eventq);
printf( "There are currently %d bytes on the server's free list\n",
bytes_reserved);
printf( "%d client(s), %d channel(s), and %d event(s) (monitors)\n",
ellCount(&rsrv_free_clientQ),
ellCount(&rsrv_free_addrq),
ellCount(&rsrv_free_eventq));
if(pCaBucket){
printf( "The server's resource id conversion table:\n");
FASTLOCK(&rsrv_free_addrq_lck);
bucketShow (pCaBucket);
FASTUNLOCK(&rsrv_free_addrq_lck);
if (level>=1 && prsrv_cast_client) {
log_one_client(prsrv_cast_client, level);
}
if (level >=1u) {
bytes_reserved = 0;
bytes_reserved += sizeof(struct client)*
ellCount(&rsrv_free_clientQ);
bytes_reserved += sizeof(struct channel_in_use)*
ellCount(&rsrv_free_addrq);
bytes_reserved += (sizeof(struct event_ext)+db_sizeof_event_block())*
ellCount(&rsrv_free_eventq);
printf( "There are currently %d bytes on the server's free list\n",
bytes_reserved);
printf( "%d client(s), %d channel(s), and %d event(s) (monitors)\n",
ellCount(&rsrv_free_clientQ),
ellCount(&rsrv_free_addrq),
ellCount(&rsrv_free_eventq));
caPrintAddrList (&beaconAddrList);
if(pCaBucket){
printf( "The server's resource id conversion table:\n");
FASTLOCK(&rsrv_free_addrq_lck);
bucketShow (pCaBucket);
FASTUNLOCK(&rsrv_free_addrq_lck);
}
caPrintAddrList (&beaconAddrList);
}
return ellCount(&clientQ);
}
@@ -481,7 +484,7 @@ int client_stat(void)
* log_one_client()
*
*/
LOCAL void log_one_client(struct client *client)
LOCAL void log_one_client(struct client *client, unsigned level)
{
int i;
struct channel_in_use *pciu;
@@ -511,63 +514,68 @@ LOCAL void log_one_client(struct client *client)
CA_PROTOCOL_VERSION,
client->minor_version_number,
client->tid);
printf( "\tProtocol=%s, Socket fd=%d\n",
pproto,
client->sock);
printf( "\tSecs since last send %6.2f, Secs since last receive %6.2f\n",
send_delay/sysClkRateGet(),
recv_delay/sysClkRateGet());
printf( "\tUnprocessed request bytes=%d, Undelivered response bytes=%d\n",
client->send.stk,
client->recv.cnt - client->recv.stk);
bytes_reserved = 0;
bytes_reserved += sizeof(struct client);
FASTLOCK(&client->addrqLock);
pciu = (struct channel_in_use *) client->addrq.node.next;
while (pciu){
bytes_reserved += sizeof(struct channel_in_use);
bytes_reserved +=
(sizeof(struct event_ext)+db_sizeof_event_block())*
ellCount(&pciu->eventq);
if(pciu->pPutNotify){
bytes_reserved += sizeof(*pciu->pPutNotify);
bytes_reserved += pciu->pPutNotify->valueSize;
}
pciu = (struct channel_in_use *) ellNext(&pciu->node);
if (level>=1) {
printf( "\tProtocol=%s, Socket fd=%d\n",
pproto,
client->sock);
printf(
"\tSecs since last send %6.2f, Secs since last receive %6.2f\n",
send_delay/sysClkRateGet(),
recv_delay/sysClkRateGet());
printf(
"\tUnprocessed request bytes=%lu, Undelivered response bytes=%lu\n",
client->send.stk,
client->recv.cnt - client->recv.stk);
psaddr = &client->addr;
printf(
"\tRemote address %lu.%lu.%lu.%lu Remote port %d state=%s\n",
(psaddr->sin_addr.s_addr & 0xff000000) >> 24,
(psaddr->sin_addr.s_addr & 0x00ff0000) >> 16,
(psaddr->sin_addr.s_addr & 0x0000ff00) >> 8,
(psaddr->sin_addr.s_addr & 0x000000ff),
psaddr->sin_port,
state[client->disconnect?1:0]);
}
FASTUNLOCK(&client->addrqLock);
psaddr = &client->addr;
printf("\tRemote address %u.%u.%u.%u Remote port %d state=%s\n",
(psaddr->sin_addr.s_addr & 0xff000000) >> 24,
(psaddr->sin_addr.s_addr & 0x00ff0000) >> 16,
(psaddr->sin_addr.s_addr & 0x0000ff00) >> 8,
(psaddr->sin_addr.s_addr & 0x000000ff),
psaddr->sin_port,
state[client->disconnect?1:0]);
printf( "\tChannel count %d\n", ellCount(&client->addrq));
printf( "\t%d bytes allocated\n", bytes_reserved);
FASTLOCK(&client->addrqLock);
pciu = (struct channel_in_use *) client->addrq.node.next;
i=0;
while (pciu){
printf( "\t%s(%d%c%c)",
pciu->addr.precord,
ellCount(&pciu->eventq),
asCheckGet(pciu->asClientPVT)?'r':'-',
asCheckPut(pciu->asClientPVT)?'w':'-');
pciu = (struct channel_in_use *) ellNext(&pciu->node);
if( ++i % 3 == 0){
printf("\n");
if (level>=2u) {
bytes_reserved = 0;
bytes_reserved += sizeof(struct client);
FASTLOCK(&client->addrqLock);
pciu = (struct channel_in_use *) client->addrq.node.next;
while (pciu){
bytes_reserved += sizeof(struct channel_in_use);
bytes_reserved +=
(sizeof(struct event_ext)+db_sizeof_event_block())*
ellCount(&pciu->eventq);
if(pciu->pPutNotify){
bytes_reserved += sizeof(*pciu->pPutNotify);
bytes_reserved += pciu->pPutNotify->valueSize;
}
pciu = (struct channel_in_use *) ellNext(&pciu->node);
}
FASTUNLOCK(&client->addrqLock);
printf( "\t%ld bytes allocated\n", bytes_reserved);
FASTLOCK(&client->addrqLock);
pciu = (struct channel_in_use *) client->addrq.node.next;
i=0;
while (pciu){
printf( "\t%s(%d%c%c)",
pciu->addr.precord,
ellCount(&pciu->eventq),
asCheckGet(pciu->asClientPVT)?'r':'-',
asCheckPut(pciu->asClientPVT)?'w':'-');
pciu = (struct channel_in_use *) ellNext(&pciu->node);
if( ++i % 3 == 0){
printf("\n");
}
}
FASTUNLOCK(&client->addrqLock);
printf("\n");
}
FASTUNLOCK(&client->addrqLock);
printf("\n");
}

View File

@@ -219,8 +219,8 @@ int cast_server(void)
continue;
}
prsrv_cast_client->recv.cnt = status;
prsrv_cast_client->recv.stk = 0;
prsrv_cast_client->recv.cnt = (unsigned long) status;
prsrv_cast_client->recv.stk = 0ul;
prsrv_cast_client->ticks_at_last_recv = tickGet();
/*
@@ -241,7 +241,7 @@ int cast_server(void)
}
if(CASDEBUG>1){
logMsg( "CAS: cast server msg of %d bytes\n",
logMsg( "CAS: cast server msg of %lu bytes\n",
prsrv_cast_client->recv.cnt,
NULL,
NULL,
@@ -267,7 +267,7 @@ int cast_server(void)
if(prsrv_cast_client->recv.cnt !=
prsrv_cast_client->recv.stk){
logMsg( "CAS: partial UDP msg of %d bytes ?\n",
logMsg( "CAS: partial UDP msg of %lu bytes ?\n",
prsrv_cast_client->recv.cnt-
prsrv_cast_client->recv.stk,
NULL,
@@ -331,7 +331,7 @@ LOCAL void clean_addrq()
pnextciu = (struct channel_in_use *)
prsrv_cast_client->addrq.node.next;
while(pciu = pnextciu){
while ( (pciu = pnextciu) ) {
pnextciu = (struct channel_in_use *)pciu->node.next;
if (current >= pciu->ticks_at_creation) {
@@ -450,10 +450,10 @@ struct client *create_udp_client(unsigned sock)
ellInit(&client->putNotifyQue);
bfill((char *)&client->addr, sizeof(client->addr), 0);
client->tid = taskIdSelf();
client->send.stk = 0;
client->send.cnt = 0;
client->recv.stk = 0;
client->recv.cnt = 0;
client->send.stk = 0ul;
client->send.cnt = 0ul;
client->recv.stk = 0ul;
client->recv.cnt = 0ul;
client->evuser = NULL;
client->eventsoff = FALSE;
client->disconnect = FALSE; /* for TCP only */

View File

@@ -87,7 +87,7 @@ struct message_buffer{
char buf[MAX_MSG_SIZE];
unsigned long stk;
unsigned long maxstk;
long cnt;
unsigned long cnt;
};
struct client{
@@ -230,7 +230,7 @@ caHdr *cas_alloc_msg();
int rsrv_online_notify_task();
void cac_send_heartbeat();
int client_stat(void);
int client_stat(unsigned level);
int req_server(void);
int cast_server(void);
int free_client(struct client *client);