while ((r = silc_dlist_get(server->pending_commands)) != SILC_LIST_END) {
if (r->reply_cmd == reply_cmd && r->ident == ident) {
silc_dlist_del(server->pending_commands, r);
+ silc_free(r);
break;
}
}
break;
}
+ silc_id_payload_free(idp);
silc_free(id);
}
}
silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
SILC_STATUS_ERR_AUTH_FAILED,
0);
+ silc_pkcs_public_key_free(channel->founder_key);
+ channel->founder_key = NULL;
goto out;
}
}
client->mode |= SILC_UMODE_SERVER_OPERATOR;
/* Update statistics */
- if (client->connection)
+ if (SILC_IS_LOCAL(client))
server->stat.my_server_ops++;
if (server->server_type == SILC_ROUTER)
server->stat.server_ops++;
/* Remove operator privileges, since the client may resume in some
other server which to it does not have operator privileges. */
- client->mode &= ~(SILC_UMODE_SERVER_OPERATOR |
- SILC_UMODE_ROUTER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
/* Send the user mode notify to notify that client is detached */
client->mode |= SILC_UMODE_DETACHED;
client->mode |= SILC_UMODE_ROUTER_OPERATOR;
/* Update statistics */
- if (client->connection)
+ if (SILC_IS_LOCAL(client))
server->stat.my_router_ops++;
if (server->server_type == SILC_ROUTER)
server->stat.router_ops++;
if (client) {
silc_server_remove_from_channels(server, NULL, client, TRUE,
NULL, TRUE);
+ silc_idlist_del_data(client);
silc_idlist_del_client(server->global_list, client);
}
silc_free(client_id);
NULL);
if (!client) {
/* If router did not find the client the it is bogus */
- if (server->server_type != SILC_SERVER)
+ if (server->server_type != SILC_SERVER) {
+ silc_free(client_id);
goto out;
+ }
client =
silc_idlist_add_client(server->global_list, NULL, NULL, NULL,
client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
}
}
+ silc_free(client_id);
/* Do not process the notify if the client is not registered */
if (!(client->data.status & SILC_IDLIST_STATUS_REGISTERED))
silc_hash_table_add(channel->user_list, client, chl);
silc_hash_table_add(client->channels, channel, chl);
- silc_free(client_id);
channel->user_count++;
channel->disabled = FALSE;
goto out;
}
}
+ silc_free(channel_id);
if (channel->topic && !strcmp(channel->topic, tmp)) {
SILC_LOG_DEBUG(("Topic is already set and same"));
silc_server_packet_send_to_channel(server, NULL, channel, packet->type,
FALSE, packet->buffer->data,
packet->buffer->len, FALSE);
- silc_free(channel_id);
break;
case SILC_NOTIFY_TYPE_NICK_CHANGE:
if (!id2)
goto out;
client_id2 = silc_id_payload_parse_id(id2, tmp_len, NULL);
- if (!client_id2)
+ if (!client_id2) {
+ silc_free(client_id);
goto out;
+ }
SILC_LOG_DEBUG(("Old Client ID id(%s)",
silc_id_render(client_id, SILC_ID_CLIENT)));
silc_server_del_from_watcher_list(server, client);
/* Remove the client */
+ silc_idlist_del_data(client);
silc_idlist_del_client(local ? server->local_list :
server->global_list, client);
}
server->stat.detached--;
}
}
+ SILC_UMODE_STATS_UPDATE(server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_UMODE_STATS_UPDATE(router, SILC_UMODE_ROUTER_OPERATOR);
/* Change the mode */
client->mode = mode;
if (client) {
silc_server_remove_from_channels(server, NULL, client, TRUE,
NULL, TRUE);
+ silc_idlist_del_data(client);
silc_idlist_del_client(server->global_list, client);
}
silc_free(client_id);
if (!server->sockets[i])
continue;
if (!SILC_IS_LISTENER(server->sockets[i])) {
- SilcIDListData idata = server->sockets[i]->user_data;
+ SilcSocketConnection sock = server->sockets[i];
+ SilcIDListData idata = sock->user_data;
if (idata)
idata->status &= ~SILC_IDLIST_STATUS_DISABLED;
silc_server_disconnect_remote(server, server->sockets[i],
SILC_STATUS_OK,
"Server is shutting down");
+ if (sock->user_data)
+ silc_server_free_sock_user_data(server, sock,
+ "Server is shutting down");
+ silc_socket_free(sock);
} else {
silc_socket_free(server->sockets[i]);
server->sockets[i] = NULL;
SilcServerConfigConnParams *param =
(conn->param ? conn->param : &server->config->param);
+ /* Don't retry if we are shutting down. */
+ if (server->server_shutdown) {
+ silc_server_config_unref(&sconn->conn);
+ silc_free(sconn->remote_host);
+ silc_free(sconn->backup_replace_ip);
+ silc_free(sconn);
+ return;
+ }
+
SILC_LOG_INFO(("Retrying connecting to a router"));
/* Calculate next timeout */
SilcServerConfigRouter *rconn;
int sock;
+ /* Don't connect if we are shutting down. */
+ if (server->server_shutdown) {
+ silc_free(sconn->remote_host);
+ silc_free(sconn->backup_replace_ip);
+ silc_free(sconn);
+ return;
+ }
+
SILC_LOG_INFO(("Connecting to the %s %s on port %d",
(sconn->backup ? "backup router" : "router"),
sconn->remote_host, sconn->remote_port));
SilcServerConnection sconn;
SilcServerConfigRouter *ptr;
+ /* Don't connect if we are shutting down. */
+ if (server->server_shutdown)
+ return;
+
SILC_LOG_DEBUG(("We are %s",
(server->server_type == SILC_SERVER ?
"normal server" : server->server_type == SILC_ROUTER ?
out:
/* Call the completion callback to indicate that we've connected to
the router */
- if (sconn->callback)
+ if (sconn && sconn->callback)
(*sconn->callback)(server, id_entry, sconn->callback_context);
/* Free the temporary connection data context */
int notify,
const char *signoff)
{
- FreeClientInternal i = silc_calloc(1, sizeof(*i));
-
SILC_LOG_DEBUG(("Freeing client data"));
#if 1
silc_schedule_task_del_by_context(server->schedule, client);
/* We will not delete the client entry right away. We will take it
- into history (for WHOWAS command) for 5 minutes */
- i->server = server;
- i->client = client;
- silc_schedule_task_add(server->schedule, 0,
- silc_server_free_client_data_timeout,
- (void *)i, 300, 0,
- SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
- client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
- client->data.status &= ~SILC_IDLIST_STATUS_LOCAL;
- client->mode = 0;
- client->router = NULL;
- client->connection = NULL;
+ into history (for WHOWAS command) for 5 minutes, unless we're
+ shutting down server. */
+ if (!server->server_shutdown) {
+ FreeClientInternal i = silc_calloc(1, sizeof(*i));
+ i->server = server;
+ i->client = client;
+ silc_schedule_task_add(server->schedule, 0,
+ silc_server_free_client_data_timeout,
+ (void *)i, 300, 0,
+ SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
+ client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
+ client->data.status &= ~SILC_IDLIST_STATUS_LOCAL;
+ client->mode = 0;
+ client->router = NULL;
+ client->connection = NULL;
+ } else {
+ /* Delete directly since we're shutting down server */
+ silc_idlist_del_data(client);
+ silc_idlist_del_client(server->local_list, client);
+ }
}
/* Frees user_data pointer from socket connection object. This also sends
SilcUInt32 detached; /* All clients detached */
SilcUInt32 server_ops; /* All server operators */
SilcUInt32 router_ops; /* All router operators */
+ /* More to add
+ SilcUInt32 secret_channels;
+ SilcUInt32 private_channels;
+ */
/* General */
SilcUInt32 conn_attempts; /* Connection attempts */
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
id_cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
} else {
+ silc_idlist_del_data(client);
silc_idlist_del_client(server->local_list, client);
}
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
id_cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
} else {
+ silc_idlist_del_data(client);
silc_idlist_del_client(server->global_list, client);
}
silc_idcache_list_free(list);
}
+ /* Return now if we are shutting down */
+ if (server->server_shutdown) {
+ silc_hash_table_free(channels);
+
+ if (server_signoff) {
+ for (i = 0; i < argc; i++)
+ silc_free(argv[i]);
+ silc_free(argv);
+ silc_free(argv_lens);
+ silc_free(argv_types);
+ silc_hash_table_free(clients);
+ }
+ return TRUE;
+ }
+
/* Send the SERVER_SIGNOFF notify */
if (server_signoff) {
SilcBuffer args, not;
silc_hash_table_free(clients);
}
- /* Return now if we are shutting down */
- if (server->server_shutdown) {
- silc_hash_table_free(channels);
- return TRUE;
- }
-
/* We must now re-generate the channel key for all channels that had
this server's client(s) on the channel. As they left the channel we
must re-generate the channel key. */
SilcHashTableList htl;
bool delchan = !(channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH);
- if (delchan) {
+ if (delchan || server->server_shutdown) {
/* Update statistics */
if (server->server_type == SILC_ROUTER)
server->stat.chanclients -= channel->user_count;
}
/* Remove remote client */
+ silc_idlist_del_data(remote_client);
if (!silc_idlist_del_client(server->global_list, remote_client)) {
/* Remove this client from watcher list if it is */
silc_server_del_from_watcher_list(server, remote_client);
while ((r = silc_dlist_get(conn->pending_commands)) != SILC_LIST_END) {
if (r->reply_cmd == reply_cmd && r->ident == ident) {
silc_dlist_del(conn->pending_commands, r);
+ silc_free(r);
break;
}
}
* DESCRIPTION
*
* Parses buffer and return ID payload into payload structure. The
- * `buffer' is raw payload buffer.
+ * `buffer' is raw payload buffer. The caller must free the returned
+ * payload.
*
***/
SilcIDPayload silc_id_payload_parse(const unsigned char *payload,