From 4993b03b9ccd85373a60f9cf5c8d99a865898fda Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 17 Jan 2009 11:42:07 +0200 Subject: [PATCH] silcd: increment stat.clients statistics whenever adding new client When new client is added to server the stat.clients must always be incremented. Otherwise it is possible to go under zero when removing the clients by server. --- apps/silcd/command_reply.c | 10 +++++++++- apps/silcd/packet_receive.c | 8 +++++++- apps/silcd/server.c | 17 ++++++++++++++--- apps/silcd/server_util.c | 4 ++-- configure.ad | 2 +- distdir/autodist.conf | 2 +- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index b54126cf..a31588d6 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -236,6 +236,10 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd) client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING; client->mode = mode; client->servername = servername[0] ? strdup(servername) : NULL; + + SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients, + server->stat.clients + 1)); + server->stat.clients++; } else { /* We have the client already, update the data */ @@ -660,6 +664,10 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd) client->data.status |= SILC_IDLIST_STATUS_REGISTERED; client->data.status |= SILC_IDLIST_STATUS_RESOLVED; client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING; + + SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients, + server->stat.clients + 1)); + server->stat.clients++; } else { /* We have the client already, update the data */ @@ -1242,7 +1250,7 @@ SILC_SERVER_CMD_REPLY_FUNC(stats) SILC_STR_END); } - SILC_LOG_DEBUG(("stat.clients = %d\n", server->stat.clients)); + SILC_LOG_DEBUG(("stat.clients = %d", server->stat.clients)); out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_STATS); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 0d96f7bb..2d9ce41f 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 Pekka Riikonen + Copyright (C) 1997 - 2009 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -186,6 +186,12 @@ static void silc_server_notify_process(SilcServer server, } client->data.status |= SILC_IDLIST_STATUS_REGISTERED; + + if (idata->conn_type == SILC_CONN_SERVER) + server->stat.cell_clients++; + SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients, + server->stat.clients + 1)); + server->stat.clients++; } } diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 9924e8be..9fb4aaf3 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2008 Pekka Riikonen + Copyright (C) 1997 - 2009 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -318,9 +318,16 @@ static void silc_server_packet_parse_type(SilcServer server, { SilcPacketType type = packet->type; SilcIDListData idata = silc_packet_get_context(sock); +#ifdef SILC_DEBUG + const char *ip; + SilcUInt16 port; + + silc_socket_stream_get_info(silc_packet_stream_get_stream(sock), + NULL, NULL, &ip, &port); +#endif /* SILC_DEBUG */ - SILC_LOG_DEBUG(("Received %s packet [flags %d]", - silc_get_packet_name(type), packet->flags)); + SILC_LOG_DEBUG(("Received %s packet [flags %d] from %s:%d", + silc_get_packet_name(type), packet->flags, ip, port)); /* Parse the packet type */ switch (type) { @@ -5045,6 +5052,10 @@ void silc_server_save_users_on_channel(SilcServer server, } client->data.status |= SILC_IDLIST_STATUS_REGISTERED; + + SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients, + server->stat.clients + 1)); + server->stat.clients++; } if (!(client->data.status & SILC_IDLIST_STATUS_REGISTERED)) { diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 1b8249a5..7df40885 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -42,8 +42,8 @@ silc_server_remove_clients_channels(SilcServer server, if (!client) return; - SILC_LOG_DEBUG(("Remove client %s from all channels", - client->nickname ? client->nickname : + SILC_LOG_DEBUG(("Remove client %p %s from all channels", + client, client->nickname ? client->nickname : (unsigned char *)"")); if (silc_hash_table_find(clients, client, NULL, NULL)) diff --git a/configure.ad b/configure.ad index 9a1cf5bb..21d47d37 100644 --- a/configure.ad +++ b/configure.ad @@ -121,7 +121,7 @@ done __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)" #endif SILC_DIST_TOOLKIT -LT_INIT +AC_PROG_LIBTOOL AC_PROG_RANLIB #ifndef SILC_DIST_TOOLKIT AC_DISABLE_SHARED diff --git a/distdir/autodist.conf b/distdir/autodist.conf index 22cc82ba..8a279ae8 100644 --- a/distdir/autodist.conf +++ b/distdir/autodist.conf @@ -46,4 +46,4 @@ LIBTOOLIZE="libtoolize --automake --copy" # Location of the make program. This must be specified in order to be # able to create distributions. # -MAKE="gmake" +MAKE="make" -- 2.24.0