Browse Source

Tidy up debug messages

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
138967dd6b
1 changed files with 24 additions and 9 deletions
  1. 24
    9
      src/net/stream.c

+ 24
- 9
src/net/stream.c View File

@@ -45,6 +45,24 @@ void stream_associate ( struct stream_application *app,
45 45
 	app->conn = conn;
46 46
 }
47 47
 
48
+/**
49
+ * Disassociate application from connection
50
+ *
51
+ * @v app		Stream application
52
+ * @v conn		Stream connection
53
+ */
54
+static void stream_disassociate ( struct stream_application *app,
55
+				  struct stream_connection *conn ) {
56
+
57
+	DBGC ( app, "Stream %p disassociating from connection %p\n",
58
+	       app, conn );
59
+
60
+	assert ( conn->app == app );
61
+	assert ( app->conn == conn );
62
+	conn->app = NULL;
63
+	app->conn = NULL;	
64
+}
65
+
48 66
 /**
49 67
  * Connection established
50 68
  *
@@ -76,18 +94,16 @@ void stream_connected ( struct stream_connection *conn ) {
76 94
 void stream_closed ( struct stream_connection *conn, int rc ) {
77 95
 	struct stream_application *app = conn->app;
78 96
 
79
-	DBGC ( app, "Stream %p closed (%s)\n", app, strerror ( rc ) );
80
-
81 97
 	/* Check connection actually exists */
82 98
 	if ( ! app ) {
83
-		DBGC ( conn, "Stream connection %p has no application\n",
84
-		       conn );
99
+		/* Not an error; don't display a debug message */
85 100
 		return;
86 101
 	}
87 102
 
103
+	DBGC ( app, "Stream %p closed (%s)\n", app, strerror ( rc ) );
104
+
88 105
 	/* Disassociate application from connection */
89
-	app->conn = NULL;
90
-	conn->app = NULL;
106
+	stream_disassociate ( app, conn );
91 107
 
92 108
 	/* Hand off to application */
93 109
 	if ( app->op->closed )
@@ -244,13 +260,12 @@ void stream_close ( struct stream_application *app ) {
244 260
 
245 261
 	/* Check connection actually exists */
246 262
 	if ( ! conn ) {
247
-		DBGC ( app, "Stream %p has no connection\n", app );
263
+		/* Not an error; don't display a debug message */
248 264
 		return;
249 265
 	}
250 266
 
251 267
 	/* Disassociate application from connection */
252
-	app->conn = NULL;
253
-	conn->app = NULL;
268
+	stream_disassociate ( app, conn );
254 269
 
255 270
 	/* Hand off to connection */
256 271
 	if ( ! conn->op->close )

Loading…
Cancel
Save