// Close all APR memory pools and resources\r
Pool.destroy(rootPool);\r
rootPool = 0;\r
- initialized = false ;\r
+ initialized = false;\r
}\r
\r
\r
if (comet) {\r
// FIXME: Find an appropriate timeout value, for now, "longer than usual"\r
// semms appropriate\r
- timeout = soTimeout * 20;\r
+ timeout = soTimeout * 50;\r
}\r
serverPollset = allocatePoller(size, pool, timeout);\r
if (serverPollset == 0 && size > 1024) {\r
* Destroy the poller.\r
*/\r
protected void destroy() {\r
+ // Wait for polltime before doing anything, so that the poller threads\r
+ // exit, otherwise parallel descturction of sockets which are still\r
+ // in the poller can cause problems\r
+ try {\r
+ synchronized (this) {\r
+ this.wait(pollTime / 1000);\r
+ }\r
+ } catch (InterruptedException e) {\r
+ // Ignore\r
+ }\r
// Close all sockets in the add queue\r
for (int i = 0; i < addCount; i++) {\r
if (comet) {\r
// Loop if endpoint is paused\r
while (paused) {\r
try {\r
- // TODO: We can easly do the maintenance here\r
Thread.sleep(1000);\r
} catch (InterruptedException e) {\r
// Ignore\r
continue;\r
}\r
}\r
- if (soTimeout > 0 && maintainTime > 1000000L) {\r
+ if (soTimeout > 0 && maintainTime > 1000000L && running) {\r
rv = Poll.maintain(serverPollset, desc, true);\r
maintainTime = 0;\r
if (rv > 0) {\r
for (int n = 0; n < rv; n++) {\r
// Close socket and clear pool\r
if (comet) {\r
- // FIXME: should really close in case of timeout ?\r
- // FIXME: maybe comet should use an extended timeout\r
processSocket(desc[n], true);\r
} else {\r
Socket.destroy(desc[n]);\r
\r
}\r
\r
- }\r
+ synchronized (this) {\r
+ this.notifyAll();\r
+ }\r
\r
+ }\r
+ \r
}\r
\r
\r
* Destroy the poller.\r
*/\r
protected void destroy() {\r
+ // Wait for polltime before doing anything, so that the poller threads\r
+ // exit, otherwise parallel descturction of sockets which are still\r
+ // in the poller can cause problems\r
+ try {\r
+ synchronized (this) {\r
+ this.wait(pollTime / 1000);\r
+ }\r
+ } catch (InterruptedException e) {\r
+ // Ignore\r
+ }\r
// Close any socket remaining in the add queue\r
for (int i = (addS.size() - 1); i >= 0; i--) {\r
SendfileData data = addS.get(i);\r
}\r
}\r
\r
+ synchronized (this) {\r
+ this.notifyAll();\r
+ }\r
+\r
}\r
\r
}\r