From 138967dd6bc8b2cf00924e5a160184af3977a4ce Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 Jan 2007 03:05:49 +0000 Subject: [PATCH] Tidy up debug messages --- src/net/stream.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/net/stream.c b/src/net/stream.c index e255d850..bf49bb9e 100644 --- a/src/net/stream.c +++ b/src/net/stream.c @@ -45,6 +45,24 @@ void stream_associate ( struct stream_application *app, app->conn = conn; } +/** + * Disassociate application from connection + * + * @v app Stream application + * @v conn Stream connection + */ +static void stream_disassociate ( struct stream_application *app, + struct stream_connection *conn ) { + + DBGC ( app, "Stream %p disassociating from connection %p\n", + app, conn ); + + assert ( conn->app == app ); + assert ( app->conn == conn ); + conn->app = NULL; + app->conn = NULL; +} + /** * Connection established * @@ -76,18 +94,16 @@ void stream_connected ( struct stream_connection *conn ) { void stream_closed ( struct stream_connection *conn, int rc ) { struct stream_application *app = conn->app; - DBGC ( app, "Stream %p closed (%s)\n", app, strerror ( rc ) ); - /* Check connection actually exists */ if ( ! app ) { - DBGC ( conn, "Stream connection %p has no application\n", - conn ); + /* Not an error; don't display a debug message */ return; } + DBGC ( app, "Stream %p closed (%s)\n", app, strerror ( rc ) ); + /* Disassociate application from connection */ - app->conn = NULL; - conn->app = NULL; + stream_disassociate ( app, conn ); /* Hand off to application */ if ( app->op->closed ) @@ -244,13 +260,12 @@ void stream_close ( struct stream_application *app ) { /* Check connection actually exists */ if ( ! conn ) { - DBGC ( app, "Stream %p has no connection\n", app ); + /* Not an error; don't display a debug message */ return; } /* Disassociate application from connection */ - app->conn = NULL; - conn->app = NULL; + stream_disassociate ( app, conn ); /* Hand off to connection */ if ( ! conn->op->close )