summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8cb801c)
Fixed the SIGUSR1 signal handling which can be used to dump the server
internals to /tmp.
Changed also End of Stream handling to handle NULL idata pointer instead
of ignoring the EOS in case it is NULL.
Changed also the DETACH timeout handling to use the packet stream
directly instead of looking up client in the callback.
{
SilcServer server = app_context;
QuitInternal q = (QuitInternal)context;
{
SilcServer server = app_context;
QuitInternal q = (QuitInternal)context;
- SilcClientID *client_id = (SilcClientID *)q->sock;
- SilcClientEntry client;
- SilcPacketStream sock;
- SilcIDListData idata;
-
+ SilcPacketStream sock = q->sock;
+ SilcClientEntry client = silc_packet_get_context(sock);
+ SilcIDListData idata = (SilcIDListData)client;
- client = silc_idlist_find_client_by_id(server->local_list, client_id,
- TRUE, NULL);
- if (client && client->connection) {
- sock = client->connection;
+ if (!client) {
+ silc_packet_stream_unref(sock);
+ silc_free(q);
+ return;
+ }
- SILC_LOG_DEBUG(("Detaching client %s",
- silc_id_render(client->id, SILC_ID_CLIENT)));
+ SILC_LOG_DEBUG(("Detaching client %s",
+ silc_id_render(client->id, SILC_ID_CLIENT)));
- /* Stop rekey for the client. */
- silc_server_stop_rekey(server, client);
+ /* Stop rekey for the client. */
+ silc_server_stop_rekey(server, client);
- /* Abort any active protocol */
- idata = silc_packet_get_context(sock);
- if (idata && idata->sconn && idata->sconn->op) {
- SILC_LOG_DEBUG(("Abort active protocol"));
- silc_async_abort(idata->sconn->op, NULL, NULL);
- idata->sconn->op = NULL;
- }
+ /* Abort any active protocol */
+ idata = silc_packet_get_context(sock);
+ if (idata && idata->sconn && idata->sconn->op) {
+ SILC_LOG_DEBUG(("Abort active protocol"));
+ silc_async_abort(idata->sconn->op, NULL, NULL);
+ idata->sconn->op = NULL;
+ }
- /* Close the connection on our side */
- client->router = NULL;
- client->connection = NULL;
- silc_server_close_connection(server, sock);
+ /* Close the connection on our side */
+ client->router = NULL;
+ client->connection = NULL;
+ silc_server_close_connection(server, sock);
- /* Mark the client as locally detached. */
- client->local_detached = TRUE;
+ /* Mark the client as locally detached. */
+ client->local_detached = TRUE;
- /*
- * Decrement the user count; we'll increment it if the user resumes on our
- * server.
- */
- SILC_VERIFY(&server->stat.my_clients > 0);
- server->stat.my_clients--;
- }
+ /* Decrement the user count; we'll increment it if the user resumes on our
+ server. */
+ SILC_VERIFY(&server->stat.my_clients > 0);
+ server->stat.my_clients--;
+ silc_packet_stream_unref(sock);
SILC_NOTIFY_TYPE_UMODE_CHANGE);
q = silc_calloc(1, sizeof(*q));
SILC_NOTIFY_TYPE_UMODE_CHANGE);
q = silc_calloc(1, sizeof(*q));
- q->sock = silc_id_dup(client->id, SILC_ID_CLIENT);
+ q->sock = cmd->sock;
+ silc_packet_stream_ref(q->sock);
silc_schedule_task_add_timeout(server->schedule,
silc_server_command_detach_cb,
q, 0, 200000);
if (server->config->detach_timeout) {
q = silc_calloc(1, sizeof(*q));
silc_schedule_task_add_timeout(server->schedule,
silc_server_command_detach_cb,
q, 0, 200000);
if (server->config->detach_timeout) {
q = silc_calloc(1, sizeof(*q));
- q->sock = silc_id_dup(client->id, SILC_ID_CLIENT);
+ q->sock = (void *)silc_id_dup(client->id, SILC_ID_CLIENT);
silc_schedule_task_add_timeout(server->schedule,
silc_server_command_detach_timeout,
q, server->config->detach_timeout * 60, 0);
silc_schedule_task_add_timeout(server->schedule,
silc_server_command_detach_timeout,
q, server->config->detach_timeout * 60, 0);
SILC_LOG_DEBUG(("End of stream received, sock %p", stream));
SILC_LOG_DEBUG(("End of stream received, sock %p", stream));
- if (!idata)
- return;
-
if (server->router_conn && server->router_conn->sock == stream &&
!server->router && server->standalone) {
if (server->router_conn && server->router_conn->sock == stream &&
!server->router && server->standalone) {
- if (idata->sconn && idata->sconn->callback)
+ if (idata && idata->sconn && idata->sconn->callback)
(*idata->sconn->callback)(server, NULL, idata->sconn->callback_context);
silc_server_create_connections(server);
silc_server_free_sock_user_data(server, stream, NULL);
} else {
/* If backup disconnected then mark that resuming will not be allowed */
(*idata->sconn->callback)(server, NULL, idata->sconn->callback_context);
silc_server_create_connections(server);
silc_server_free_sock_user_data(server, stream, NULL);
} else {
/* If backup disconnected then mark that resuming will not be allowed */
- if (server->server_type == SILC_ROUTER && !server->backup_router &&
+ if (idata &&
+ server->server_type == SILC_ROUTER && !server->backup_router &&
idata->conn_type == SILC_CONN_SERVER) {
SilcServerEntry server_entry = (SilcServerEntry)idata;
if (server_entry->server_type == SILC_BACKUP_ROUTER)
server->backup_closed = TRUE;
}
idata->conn_type == SILC_CONN_SERVER) {
SilcServerEntry server_entry = (SilcServerEntry)idata;
if (server_entry->server_type == SILC_BACKUP_ROUTER)
server->backup_closed = TRUE;
}
- if (idata->sconn && idata->sconn->callback)
+ if (idata && idata->sconn && idata->sconn->callback)
(*idata->sconn->callback)(server, NULL, idata->sconn->callback_context);
silc_server_free_sock_user_data(server, stream, NULL);
}
(*idata->sconn->callback)(server, NULL, idata->sconn->callback_context);
silc_server_free_sock_user_data(server, stream, NULL);
}
silc_server_free_sock_user_data(server, stream, NULL);
} else {
/* If backup disconnected then mark that resuming will not be allowed */
silc_server_free_sock_user_data(server, stream, NULL);
} else {
/* If backup disconnected then mark that resuming will not be allowed */
- if (server->server_type == SILC_ROUTER && !server->backup_router &&
- idata->conn_type == SILC_CONN_SERVER) {
+ if (server->server_type == SILC_ROUTER && !server->backup_router &&
+ idata->conn_type == SILC_CONN_SERVER) {
SilcServerEntry server_entry = (SilcServerEntry)idata;
if (server_entry->server_type == SILC_BACKUP_ROUTER)
server->backup_closed = TRUE;
SilcServerEntry server_entry = (SilcServerEntry)idata;
if (server_entry->server_type == SILC_BACKUP_ROUTER)
server->backup_closed = TRUE;
/* Dump internal flags */
fprintf(fdd, "\nDumping internal flags\n");
fprintf(fdd, " server_type : %d\n", silcd->server_type);
/* Dump internal flags */
fprintf(fdd, "\nDumping internal flags\n");
fprintf(fdd, " server_type : %d\n", silcd->server_type);
if (!silc_socket_stream_get_info(silc_packet_stream_get_stream(s),
&sock, &hostname, &ip, &port))
continue;
if (!silc_socket_stream_get_info(silc_packet_stream_get_stream(s),
&sock, &hostname, &ip, &port))
continue;
- fprintf(fdd, " %d: host %s ip %s port %d type %d\n",
+ fprintf(fdd, " %d: host %s ip %s port %d type %d idata %p\n",
sock, hostname ? hostname : "N/A",
sock, hostname ? hostname : "N/A",
- ip ? ip : "N/A", port, idata ? idata->conn_type : 0);
+ ip ? ip : "N/A", port, idata ? idata->conn_type : 0, idata);
}
silc_dlist_uninit(conns);
}
}
silc_dlist_uninit(conns);
}
if (silc_idcache_get_all(silcd->local_list->servers, &list)) {
c = 1;
fprintf(fdd, "\nServers in local-list:\n");
if (silc_idcache_get_all(silcd->local_list->servers, &list)) {
c = 1;
fprintf(fdd, "\nServers in local-list:\n");
while ((id_cache = silc_list_get(list))) {
server_entry = (SilcServerEntry)id_cache->context;
while ((id_cache = silc_list_get(list))) {
server_entry = (SilcServerEntry)id_cache->context;
- fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ fprintf(fdd, " %d: name %s id %s status 0x%x idata %p\n", c,
server_entry->server_name ? server_entry->server_name :
"N/A", server_entry->id ?
silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
server_entry->server_name ? server_entry->server_name :
"N/A", server_entry->id ?
silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
- server_entry->data.status);
+ server_entry->data.status, server_entry);
c++;
}
}
if (silc_idcache_get_all(silcd->global_list->servers, &list)) {
fprintf(fdd, "\nServers in global-list:\n");
c = 1;
c++;
}
}
if (silc_idcache_get_all(silcd->global_list->servers, &list)) {
fprintf(fdd, "\nServers in global-list:\n");
c = 1;
while ((id_cache = silc_list_get(list))) {
server_entry = (SilcServerEntry)id_cache->context;
while ((id_cache = silc_list_get(list))) {
server_entry = (SilcServerEntry)id_cache->context;
- fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ fprintf(fdd, " %d: name %s id %s status 0x%x idata %p\n", c,
server_entry->server_name ? server_entry->server_name :
"N/A", server_entry->id ?
silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
server_entry->server_name ? server_entry->server_name :
"N/A", server_entry->id ?
silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
- server_entry->data.status);
+ server_entry->data.status, server_entry);
c++;
}
}
if (silc_idcache_get_all(silcd->local_list->clients, &list)) {
fprintf(fdd, "\nClients in local-list:\n");
c = 1;
c++;
}
}
if (silc_idcache_get_all(silcd->local_list->clients, &list)) {
fprintf(fdd, "\nClients in local-list:\n");
c = 1;
while ((id_cache = silc_list_get(list))) {
client_entry = (SilcClientEntry)id_cache->context;
server_entry = client_entry->router;
while ((id_cache = silc_list_get(list))) {
client_entry = (SilcClientEntry)id_cache->context;
server_entry = client_entry->router;
- fprintf(fdd, " %d: name %s id %s status 0x%x from %s\n", c,
+ fprintf(fdd, " %d: name %s id %s status 0x%x from %s idata %p\n", c,
client_entry->nickname ? client_entry->nickname :
(unsigned char *)"N/A", client_entry->id ?
silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
client_entry->data.status, server_entry ?
server_entry->server_name ? server_entry->server_name :
client_entry->nickname ? client_entry->nickname :
(unsigned char *)"N/A", client_entry->id ?
silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
client_entry->data.status, server_entry ?
server_entry->server_name ? server_entry->server_name :
+ "N/A" : "local", client_entry);
c++;
}
}
if (silc_idcache_get_all(silcd->global_list->clients, &list)) {
fprintf(fdd, "\nClients in global-list:\n");
c = 1;
c++;
}
}
if (silc_idcache_get_all(silcd->global_list->clients, &list)) {
fprintf(fdd, "\nClients in global-list:\n");
c = 1;
while ((id_cache = silc_list_get(list))) {
client_entry = (SilcClientEntry)id_cache->context;
server_entry = client_entry->router;
while ((id_cache = silc_list_get(list))) {
client_entry = (SilcClientEntry)id_cache->context;
server_entry = client_entry->router;
- fprintf(fdd, " %d: name %s id %s status 0x%x from %s\n", c,
+ fprintf(fdd, " %d: name %s id %s status 0x%x from %s idata %p\n", c,
client_entry->nickname ? client_entry->nickname :
(unsigned char *)"N/A", client_entry->id ?
silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
client_entry->data.status, server_entry ?
server_entry->server_name ? server_entry->server_name :
client_entry->nickname ? client_entry->nickname :
(unsigned char *)"N/A", client_entry->id ?
silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
client_entry->data.status, server_entry ?
server_entry->server_name ? server_entry->server_name :
+ "N/A" : "local", client_entry);
c++;
}
}
if (silc_idcache_get_all(silcd->local_list->channels, &list)) {
fprintf(fdd, "\nChannels in local-list:\n");
c = 1;
c++;
}
}
if (silc_idcache_get_all(silcd->local_list->channels, &list)) {
fprintf(fdd, "\nChannels in local-list:\n");
c = 1;
while ((id_cache = silc_list_get(list))) {
channel_entry = (SilcChannelEntry)id_cache->context;
fprintf(fdd, " %d: name %s id %s\n", c,
while ((id_cache = silc_list_get(list))) {
channel_entry = (SilcChannelEntry)id_cache->context;
fprintf(fdd, " %d: name %s id %s\n", c,
if (silc_idcache_get_all(silcd->global_list->channels, &list)) {
fprintf(fdd, "\nChannels in global-list:\n");
c = 1;
if (silc_idcache_get_all(silcd->global_list->channels, &list)) {
fprintf(fdd, "\nChannels in global-list:\n");
c = 1;
while ((id_cache = silc_list_get(list))) {
channel_entry = (SilcChannelEntry)id_cache->context;
fprintf(fdd, " %d: name %s id %s\n", c,
while ((id_cache = silc_list_get(list))) {
channel_entry = (SilcChannelEntry)id_cache->context;
fprintf(fdd, " %d: name %s id %s\n", c,
fflush(fdd);
fclose(fdd);
fflush(fdd);
fclose(fdd);