From e0668bd1d448d6f17c20b9c7ba91344180809061 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 6 Jan 2010 14:20:19 -0800 Subject: [PATCH] Check invariants earlier in vconn and stream code. 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 | 1 + lib/vconn.c | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/stream.c b/lib/stream.c index 23b25f22..337fb5c7 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -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 diff --git a/lib/vconn.c b/lib/vconn.c index b11650fb..7b9ae610 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -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 -- 2.30.2