DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2652
Version: 1.3-current
Hi,
A long time ago (in 2005) I found a bug in FLTK-2.x's code that
watches file descriptors, and submitted a patch to Michael S. It
was committed and it's used in fltk-1.3 currently (unix part),
but it is not present in the Mac code.
The original patch is attached to this STR.
The bug is severe, as it can cause crashes, freezes, busy waits
etc. I'm quoting the original email below:
--
[On March 27, 2005 jcid wrote:]
Hi Michael,
Here's a patch I've been using successfuly for a few days or
so. While I was porting the IO engine of dillo to FLTK, there was
a bug that resisted a lot to dissapear. After a couple of days of
hunting I went into FLTK's sources. Short story, it's a small but
very subtle patch for src/x11/run.cxx remove_fd().
maxfd has to be recalculated every time remove_fd() is called
(in the select() based version). Checking only with the fd being
removed is not enough because there may still be another callback
attached for it, and because the new maxfd remains unknown.
I decided to leave four printf statements in the patch for you
to "see" what I mean, while testing the patch. Just remove them
if you commit ;).
Cheers
Jorge.-
--
Test case:
I don't own a Mac, nor have a simple test case, but it can be
tested against the fltk-1.3-based dillo. Building dillo natively
produces an almost working browser that freezes on busy waits. The
patch should make them disappear (as it did in 2005).
Quick recipe for dillo:
1.- <install fltk-1.3-rc5 from fltk.org>
2.- <install auto* tools, X devel, C/C++, jpeg, png, etc>
3.- <install mercurial>
4.- $ hg clone http://hg.dillo.org/dillo_port1.3
5.- $ cd dillo_port1.3
6.- $ ./autogen.sh
7.- $ CFLAGS="-g -O0" CXXFLAGS="-g -O0" ./configure --enable-ssl
8.- $ make|grep :
9.- $ sudo make install
(this will install dillo, dpid, dpidc and the dpis)
10.- $ src/dillo
Link: http://www.fltk.org/str.php?L2652
Version: 1.3-currentIndex: src/x11/run.cxx
===================================================================
--- src/x11/run.cxx (revision 4195)
+++ src/x11/run.cxx (working copy)
@@ -325,6 +325,7 @@
ignored?)
*/
void fltk::add_fd(int n, int events, FileHandler cb, void *v) {
+printf("[FLTK] add_fd begin [fd=%d nfds=%d maxfd=%d]\n",n,nfds,maxfd);
remove_fd(n,events);
int i = nfds++;
if (i >= fd_array_size) {
@@ -347,6 +348,7 @@
if (events & POLLERR) FD_SET(n, &fdsets[2]);
if (n > maxfd) maxfd = n;
#endif
+printf("[FLTK] add_fd end [fd=%d nfds=%d maxfd=%d]\n",n,nfds,maxfd);
}
/*! Same as add_fd(fd, READ, cb, v); */
@@ -363,6 +365,8 @@
*/
void fltk::remove_fd(int n, int events) {
int i,j;
+printf("[FLTK] remove_fd begin [fd=%d nfds=%d maxfd=%d]\n",n,nfds,maxfd);
+ maxfd = 0;
for (i=j=0; i<nfds; i++) {
#if USE_POLL
if (pollfds[i].fd == n) {
@@ -384,6 +388,7 @@
pollfds[j] = pollfds[i];
#endif
}
+ if (fd[j].fd > maxfd) maxfd = fd[j].fd;
j++;
}
nfds = j;
@@ -391,8 +396,8 @@
if (events & POLLIN) FD_CLR(n, &fdsets[0]);
if (events & POLLOUT) FD_CLR(n, &fdsets[1]);
if (events & POLLERR) FD_CLR(n, &fdsets[2]);
- if (n == maxfd) maxfd--;
#endif
+printf("[FLTK] remove_fd end [fd=%d nfds=%d maxfd=%d]\n",n,nfds,maxfd);
}
#if CONSOLIDATE_MOTION
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs