Check invariants earlier in vconn and stream code.
authorBen Pfaff <blp@nicira.com>
Wed, 6 Jan 2010 22:20:19 +0000 (14:20 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 6 Jan 2010 22:20:19 +0000 (14:20 -0800)
These invariants are checked by vconn_open() and stream_open(), but there
is no reason not to check them earlier also.  vconn and stream creation
don't have to go through vconn_open() and stream_open(), so this ensures
that the invariants get checked either way.

lib/stream.c
lib/vconn.c

index 23b25f22173b4ee4e5f41ce4fa71fb21a67fc39a..337fb5c754977b356f0d96a5b3178d5caf8ee5f7 100644 (file)
@@ -476,6 +476,7 @@ stream_init(struct stream *stream, struct stream_class *class,
                     : SCS_DISCONNECTED);
     stream->error = connect_status;
     stream->name = xstrdup(name);
+    assert(stream->state != SCS_CONNECTING || class->connect);
 }
 
 void
index b11650fbc8b10f5a853bb49631f81d0d47b63ad3..7b9ae610e843f681e88dfae814a303b63232ca16 100644 (file)
@@ -1444,6 +1444,7 @@ vconn_init(struct vconn *vconn, struct vconn_class *class, int connect_status,
     vconn->local_ip = 0;
     vconn->local_port = 0;
     vconn->name = xstrdup(name);
+    assert(vconn->state != VCS_CONNECTING || class->connect);
 }
 
 void