Archive for February, 2009

Metalinguistic Abstraction

Wednesday, February 25th, 2009

本文的标题其实是SICP第四章的标题,这一章的内容是迷人的,让人心醉。我们可以看到如何用Scheme实现一个Scheme解释器,如何实现惰性求值,如何在解释器内部实现非确定性计算,以及如何实现一个查询语言。收获知识的喜悦,突然想起陶潜的一句诗:“此中有真意,欲辩已忘言。”

这里有一些有趣的程序,类似SICP第五章,将Scheme代码翻译成C代码,甚至llvm汇编。

Q1的MBO也终于设定,我的英语IDP目标是技术写作 — 内容为Lisp和Ruby中的DSL特性。

debug-set!

Monday, February 23rd, 2009

If you wrote a scheme procedure which will recursive too much and exhaust all you stack, guile will print a horrible error message like below:

ERROR: Stack overflow

You might fix your algorithm and make the procedure tail-recursive to get rid of the compliant, or either, for debugging purpose, increase the stack size:

(debug-set! stack 200000)

三言两语

Thursday, February 19th, 2009

当我比较专注的时候,一个明显的特征是:坐在椅子的扶手上,目不转睛地向下俯视显示器。昨天终于搞定一个烦人的臭虫,打了补丁后做测试。正当我重复这个习惯的时候,老大突然出现在一米开外:“[GQ的中文发音],你在乐什么呐?” 愣了一下,回复:“搞定一个bug,正在测试。”

我早已习惯了大家对我的称呼,只是从老大嘴里说出来的时候,还是有点汗。:-)

reconnect

Wednesday, February 18th, 2009

Several days ago there was a bug reported that our XML-RPC client over SSL will compliant that “no data is available” when trying to read the HTTP header from the server. Since it is a P2-critical bug, I spent a lot of time debugging it immediately.

GDB shows me that “BIO_read()” returned zero when reading the HTTP header, and its manual said that:
A 0 or -1 return is not necessarily an indication of an error. In par-
ticular when the source/sink is non-blocking or of a certain type it
may merely be an indication that no data is currently available and
that the application should retry the operation later.

But finally I can see that when we switching to HTTP from HTTPS, the client works just fine. And later, we are confirmed that the SSL handling in the server side has a race condition and the connection would be shutdown by then.

In order to make the client more robust, I worked our a patch to do reconnection. The result is rather exciting — I did thousands of XML-RPC calls over a persistent connection, and everything works perfectly.

At last, I am glad to share that, in section 6.3 of “UNIX Network Programming Volume 1″, the author described the conditions that a descriptor being select() is ready for read:

b. The read half of the connection is closed (i.e., a TCP connection that has received a FIN). A read operation on the socket will not block and will return 0 (i.e., EOF).

Actually our underlying socket is handled by select() , and I checked that BIO_get_close() really returns 1 when the connection is closed by the server.

1234567890

Monday, February 9th, 2009

$ date -d @1234567890
Sat Feb 14 07:31:30 CST 2009