]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polish: replace several assert(isOpen(fd))
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 10 Nov 2012 04:38:32 +0000 (21:38 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 10 Nov 2012 04:38:32 +0000 (21:38 -0700)
Reduces by over half the number of asserts which can be confused as
cache.log bug reports just says "assertion isOpen(fd)" in comm.cc

src/comm.cc

index ace7f7b09f18bb36f8078e997a1484379f2c46f5..3f3238dfc23682f1fd39bc42937f2e5d9ad8fe90 100644 (file)
@@ -221,7 +221,7 @@ comm_has_pending_read_callback(int fd)
 bool
 comm_monitors_read(int fd)
 {
-    assert(isOpen(fd));
+    assert(isOpen(fd) && COMMIO_FD_READCB(fd));
     // Being active is usually the same as monitoring because we always
     // start monitoring the FD when we configure Comm::IoCallback for I/O
     // and we usually configure Comm::IoCallback for I/O when we starting
@@ -352,7 +352,7 @@ comm_udp_send(int s, const void *buf, size_t len, int flags)
 bool
 comm_has_incomplete_write(int fd)
 {
-    assert(isOpen(fd));
+    assert(isOpen(fd) && COMMIO_FD_WRITECB(fd));
     return COMMIO_FD_WRITECB(fd)->active();
 }
 
@@ -1227,7 +1227,7 @@ comm_add_close_handler(int fd, AsyncCall::Pointer &call)
 void
 comm_remove_close_handler(int fd, CLCB * handler, void *data)
 {
-    assert (isOpen(fd));
+    assert(isOpen(fd));
     /* Find handler in list */
     debugs(5, 5, "comm_remove_close_handler: FD " << fd << ", handler=" <<
            handler << ", data=" << data);
@@ -1256,7 +1256,7 @@ comm_remove_close_handler(int fd, CLCB * handler, void *data)
 void
 comm_remove_close_handler(int fd, AsyncCall::Pointer &call)
 {
-    assert (isOpen(fd));
+    assert(isOpen(fd));
     debugs(5, 5, "comm_remove_close_handler: FD " << fd << ", AsyncCall=" << call);
 
     // comm_close removes all close handlers so our handler may be gone
@@ -1829,8 +1829,7 @@ void
 commStartHalfClosedMonitor(int fd)
 {
     debugs(5, 5, HERE << "adding FD " << fd << " to " << *TheHalfClosed);
-    assert(isOpen(fd));
-    assert(!commHasHalfClosedMonitor(fd));
+    assert(isOpen(fd) && !commHasHalfClosedMonitor(fd));
     (void)TheHalfClosed->add(fd); // could also assert the result
     commPlanHalfClosedCheck(); // may schedule check if we added the first FD
 }