static void client_destroy(struct client *client) { char **app; i_set_failure_prefix("imap-urlauth[%s](%s): ", my_pid, client->access_user); if (client->url != NULL) { /* deinitialize url */ i_stream_close(client->input); o_stream_close(client->output); (void)client_run_url(client); i_assert(client->url == NULL); } imap_urlauth_worker_client_count--; DLLIST_REMOVE(&imap_urlauth_worker_clients, client); if (client->urlauth_ctx != NULL) imap_urlauth_deinit(&client->urlauth_ctx); if (client->mail_user != NULL) mail_user_unref(&client->mail_user); if (client->io != NULL) io_remove(&client->io); if (client->ctrl_io != NULL) io_remove(&client->ctrl_io); if (client->to_idle != NULL) timeout_remove(&client->to_idle); if (client->input != NULL) i_stream_destroy(&client->input); if (client->output != NULL) o_stream_destroy(&client->output); if (client->ctrl_input != NULL) i_stream_destroy(&client->ctrl_input); if (client->ctrl_output != NULL) o_stream_destroy(&client->ctrl_output); if (client->fd_in >= 0) net_disconnect(client->fd_in); if (client->fd_out >= 0 && client->fd_in != client->fd_out) net_disconnect(client->fd_out); if (client->fd_ctrl >= 0) net_disconnect(client->fd_ctrl); if (client->service_user != NULL) mail_storage_service_user_free(&client->service_user); i_free(client->access_user); array_foreach_modifiable(&client->access_apps, app) i_free(*app); array_free(&client->access_apps); i_free(client); imap_urlauth_worker_refresh_proctitle(); master_service_client_connection_destroyed(master_service); }
void client_destroy(struct client *client, const char *prefix, const char *reason) { if (client->destroyed) return; client->destroyed = TRUE; client_disconnect(client, prefix, reason); submission_client_count--; DLLIST_REMOVE(&submission_clients, client); if (client->proxy_conn != NULL) smtp_client_connection_close(&client->proxy_conn); if (client->anvil_sent) { master_service_anvil_send(master_service, t_strconcat( "DISCONNECT\t", my_pid, "\tsubmission/", mail_user_get_anvil_userip_ident(client->user), "\n", NULL)); } if (client->urlauth_ctx != NULL) imap_urlauth_deinit(&client->urlauth_ctx); mail_user_unref(&client->user); mail_storage_service_user_unref(&client->service_user); client_state_reset(client); i_free(client->session_id); i_free(client); master_service_client_connection_destroyed(master_service); submission_refresh_proctitle(); }
static void client_default_destroy(struct client *client, const char *reason) { struct client_command_context *cmd; const char *cmd_status = ""; i_assert(!client->destroyed); client->destroyed = TRUE; if (!client->disconnected) { client->disconnected = TRUE; if (reason == NULL) { reason = io_stream_get_disconnect_reason(client->input, client->output); cmd_status = client_get_commands_status(client); } i_info("%s%s %s", reason, cmd_status, client_stats(client)); } i_stream_close(client->input); o_stream_close(client->output); /* finish off all the queued commands. */ if (client->output_cmd_lock != NULL) client_command_cancel(&client->output_cmd_lock); while (client->command_queue != NULL) { cmd = client->command_queue; client_command_cancel(&cmd); } /* handle the input_lock command last. it might have been waiting on other queued commands (although we probably should just drop the command at that point since it hasn't started running. but this may change in future). */ if (client->input_lock != NULL) client_command_cancel(&client->input_lock); if (client->mailbox != NULL) { client_search_updates_free(client); mailbox_free(&client->mailbox); } if (client->notify_ctx != NULL) imap_notify_deinit(&client->notify_ctx); if (client->urlauth_ctx != NULL) imap_urlauth_deinit(&client->urlauth_ctx); if (client->anvil_sent) { master_service_anvil_send(master_service, t_strconcat( "DISCONNECT\t", my_pid, "\timap/", mail_user_get_anvil_userip_ident(client->user), "\n", NULL)); } mail_user_unref(&client->user); if (client->free_parser != NULL) imap_parser_unref(&client->free_parser); if (client->io != NULL) io_remove(&client->io); if (client->to_idle_output != NULL) timeout_remove(&client->to_idle_output); if (client->to_delayed_input != NULL) timeout_remove(&client->to_delayed_input); timeout_remove(&client->to_idle); i_stream_destroy(&client->input); o_stream_destroy(&client->output); net_disconnect(client->fd_in); if (client->fd_in != client->fd_out) net_disconnect(client->fd_out); if (array_is_created(&client->search_saved_uidset)) array_free(&client->search_saved_uidset); if (array_is_created(&client->search_updates)) array_free(&client->search_updates); pool_unref(&client->command_pool); mail_storage_service_user_free(&client->service_user); imap_client_count--; DLLIST_REMOVE(&imap_clients, client); pool_unref(&client->pool); master_service_client_connection_destroyed(master_service); imap_refresh_proctitle(); }