From: adrian <> Date: Sun, 27 Oct 2002 20:45:06 +0000 (+0000) Subject: * remove the do {} while (1); crap - we don't need it here X-Git-Tag: SQUID_3_0_PRE1~556 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3de50fcdfed6478fa92d95de65f42bcadddf99b9;p=thirdparty%2Fsquid.git * remove the do {} while (1); crap - we don't need it here * fix the switch() statement and event handling - falling through is bad in this case as a registered event will only ever be a single type (unlike poll() where its a mask). --- diff --git a/src/comm_kqueue.cc b/src/comm_kqueue.cc index 32de27da7d..8ef6637109 100644 --- a/src/comm_kqueue.cc +++ b/src/comm_kqueue.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_kqueue.cc,v 1.4 2002/10/27 13:06:49 adrian Exp $ + * $Id: comm_kqueue.cc,v 1.5 2002/10/27 13:45:06 adrian Exp $ * * DEBUG: section 5 Socket functions * @@ -225,62 +225,60 @@ comm_select(int msec) static struct kevent ke[KE_LENGTH]; struct timespec poll_time; - do { - /* - * remember we are doing NANOseconds here, not micro/milli. God knows - * why jlemon used a timespec, but hey, he wrote the interface, not I - * -- Adrian - */ - poll_time.tv_sec = msec / 1000; - poll_time.tv_nsec = (msec % 1000) * 1000000; - for (;;) { - num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time); - statCounter.select_loops++; - kqoff = 0; - if (num >= 0) - break; - if (ignoreErrno(errno)) - break; - getCurrentTime(); - return COMM_ERROR; - /* NOTREACHED */ - } - + /* + * remember we are doing NANOseconds here, not micro/milli. God knows + * why jlemon used a timespec, but hey, he wrote the interface, not I + * -- Adrian + */ + poll_time.tv_sec = msec / 1000; + poll_time.tv_nsec = (msec % 1000) * 1000000; + for (;;) { + num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time); + statCounter.select_loops++; + kqoff = 0; + if (num >= 0) + break; + if (ignoreErrno(errno)) + break; getCurrentTime(); - if (num == 0) - continue; - - for (i = 0; i < num; i++) { - int fd = (int) ke[i].ident; - PF *hdl = NULL; - fde *F = &fd_table[fd]; - - if (ke[i].flags & EV_ERROR) { - errno = ke[i].data; - /* XXX error == bad! -- adrian */ - continue; /* XXX! */ - } - switch (ke[i].filter) { + return COMM_ERROR; + /* NOTREACHED */ + } + + getCurrentTime(); + if (num == 0) + continue; + + for (i = 0; i < num; i++) { + int fd = (int) ke[i].ident; + PF *hdl = NULL; + fde *F = &fd_table[fd]; + + if (ke[i].flags & EV_ERROR) { + errno = ke[i].data; + /* XXX error == bad! -- adrian */ + continue; /* XXX! */ + } + switch (ke[i].filter) { case EVFILT_READ: if ((hdl = F->read_handler) != NULL) { F->read_handler = NULL; hdl(fd, F->read_data); } + break; case EVFILT_WRITE: if ((hdl = F->write_handler) != NULL) { F->write_handler = NULL; hdl(fd, F->write_data); } + break; default: /* Bad! -- adrian */ + debug(5, 1) ("comm_select: kevent returned %d!\n", fe[i].filter); break; - } } - return COMM_OK; } - while (0); /* XXX should rip this out! -- adrian */ - /* XXX Get here, we broke! */ - return 0; + return COMM_OK; } #endif /* USE_KQUEUE */