<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>+ qitab-devel</div><br><div><div>On Apr 25, 2014, at 15:00 , 昊 谢 <<a href="mailto:xiehao@outlook.com">xiehao@outlook.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">HI Francois-Rene Rideau, qitab-devel,<div><br></div><div>I encountered a problem when I’m using your quux-hunchentoot and I have a simple way to fix it. Could you please consider it?</div><div><br></div><div>When I’m using the thread-pooling taskmaster and starting acceptor, there may be an error invoked occasionally like this:</div><div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">debugger invoked on a SIMPLE-ERROR in thread</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">#<THREAD "quux-hunchentoot-dispatcher-*:8080" RUNNING {10035DDF03}>:</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">  The assertion</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200); position: static; z-index: auto;">  (EQ QUUX-HUNCHENTOOT::DISPATCHER-PROCESS (BORDEAUX-THREADS:CURRENT-THREAD))</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200); position: static; z-index: auto;">  failed with QUUX-HUNCHENTOOT::DISPATCHER-PROCESS = NIL,</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">  (BORDEAUX-THREADS:CURRENT-THREAD) =</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">  #<SB-THREAD:THREAD "quux-hunchentoot-dispatcher-*:8080" RUNNING {10035DDF03}>.</div></div><div><br></div><div>I think the reason for this is quite straightforward. While the method “<span style="background-color: rgb(255, 255, 255); font-family: monospace; white-space: pre;">execute-acceptor</span>” is creating dispatcher thread and set it by the dispatcher-process accessor of taskmaster, we can’t imagine the “setf” action comes first. In other words, if dispatcher thread started before the accessor was set, the assertion in ensure-dispatcher-process may fail.</div><div><br></div><div>My solution for this is quite simple and here’s the effective solution, adding something like a spin-lock.</div><div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(213, 210, 76); background-color: rgb(44, 103, 200);"><b>diff --git a/thread-pooling.lisp b/thread-pooling.lisp</b></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(213, 210, 76); background-color: rgb(44, 103, 200);"><b>index dcb3427..8f3f32b 100644</b></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(213, 210, 76); background-color: rgb(44, 103, 200);"><b>--- a/thread-pooling.lisp</b></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(213, 210, 76); background-color: rgb(44, 103, 200);"><b>+++ b/thread-pooling.lisp</b></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);"><span style="color: #7c1b80"><b>@@ -146,6 +146,7 @@</b></span> then the reply will be HTTP 503."))</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200); min-height: 16px;"> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);"> (defmethod ensure-dispatcher-process ((taskmaster thread-pooling-taskmaster))</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">   (with-taskmaster-accessors (dispatcher-process) taskmaster</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(101, 229, 81); background-color: rgb(44, 103, 200);"><b>+    (do () (dispatcher-process) (sleep 0.1))</b></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200);">     (assert (eq dispatcher-process (bt:current-thread)))))</div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200); min-height: 16px;"> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; font-family: 'Courier New'; color: rgb(255, 255, 255); background-color: rgb(44, 103, 200); position: static; z-index: auto;"> (defmethod decrement-taskmaster-accept-count ((taskmaster thread-pooling-taskmaster))</div></div><div></div><div><br></div><div>Maybe you can get a better patch to solve this problem and I’m looking forward your reply.</div><div><br></div><div>Thanks & have a good day</div><div>Hao Xie</div></div></blockquote></div><br></body></html>