0. I am reading the source code of Tomcat 6.0.26. To pay off the effort,
I documents some notes for record. Thanks for the articles about Tomcat
source code, especially the book <<How Tomcat works>>.
1. They are two concepts about server, one is called Server, which
is for managing the Tomcat (start and stop); another is called Connector,
which is the server to serve the application request. they are on the different
ports. The server.xml clearly show the difference.
<Server port="8005" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
although the server is the top level element, logically it should not be.
Actually in code, Bootstrap starts the service first, which
in turn start the Server and server's services.
2. My focus in on Connector part. I care how the request is services by the
Tomcat. Here are some key classes.
Connector --> ProtocolHandler (HttpProtocol
and AjpProtocol) --> JIoEndPoint
--> Handler(Http11ConnectionHandler
and AjpConnectionHandler)
3. Connector is most obervious class, but the entry point is not here.
The sequence is like this.
Connector.Acceptor.run()
--> JioEndPoint.processSocke(Socket socket)
-->SockeProcess.run()
-->Http11ConnectorHandler.process(Socket socket)
-->Http11Processor.process(Socket socket)
-->CoyoteAdapter.service(Request req, Response res)
The core logic is in method Http11Processor.process(Socket socket)
CoyoteAdapter.service(Request req, Response res) bridges between Connector module and Container module.
Any comments are welcome. I may continue the source code reading and dig deeper into it if time permit.
It is handy to be able to navigate the source code with Ctrl + ] in Cscope, but I always forget how to navigate back and waste effort many times. So for record, Ctrl+t can navigate back in Cscope.
One more time, Ctrl+] and Ctrl+t can navigate forth and back in Cscope.
How to read the source code in <<TCP/IP Illustrated Volume 2>>
1. Get the source code, original link provided in the book is not available now.
You may need to google it.
2. install cscope and vi.
3. refer to http://cscope.sourceforge.net/large_projects.html for the following steps.
It will include all the source code of the whole OS, not only the kernel.
find src -name '*.[ch]' > cscope.files
we actually only care kernel source.
find src/sys -name '*.[ch]' > cscope.files
4. wc cscope.files
1613 1613 45585 cscope.files
5. vim
:help cscope
then you can read the help details.
6. if you run vim in the folder where cscope.out resides. then it will be loaded
automaically.
7. Try a few commands.
:cs find g mbuf
:cs find f vm.h
They works. A good start.
P.S. this book is quite old, if you know it well and can recommend some better alternative for learning TCP/IP, please post a comments, Thanks in advance.
我兒子在彈鋼琴,他阿姨說,“哥哥就喜歡彈難的。”
我外甥女說:“哥哥要彈男的。妹妹要彈女的。”
在高中的時候,知道了用篩法可以得到素數。當時我還有一個錯誤的關于尋找素數的猜測。
以為用兩個素數相乘,其附近存在素數的幾率很高。比如, 7×11 = 77, 其附近有79,正好是素數。
當時已經發現11×11=121。7×17=119;但是錯誤的理解為只有其中一個是平方或次冪時才成立。
后來有了計算機,編程驗證了一下,發現有很多的反例。對當初的錯誤猜測羞赧不已。
這個猜測雖然錯的離譜,但是和現在的素數理論,尤其是孿生素數還是很有關系的。現在已經知道,
素數有無窮多個,但是素數在自然數中所占的比例逐漸趨近于零。
因此孿生素數在自然數中的比例也是趨近于零的。現在還沒有證明孿生素數是否有無窮多個。
這個猜測的樸素之處在于,任何兩個素數之乘積A,要么A是3n+2,要么A是3n+1;如果是3n+2,則只有A+2
才有可能是素數;如果是3n+1,則只有A-2才有可能是素數。但是,事實上,這個猜測成立的比例非常的低。
寫了一個程序驗證了一下。16位的整數中,大概只有 10% 能使假設成立。
由于是在Proxy的網絡環境,MSYSGIT 的 git clone 總是失敗。需要配置如下環境變量。
export http_proxy="http://<proxy domain name>:<port>"
之后http協議git clone沒有任何問題。但是用git 協議仍舊有問題。
之后發現git push 和 git pull 經常不能work。多次嘗試后發現用更全的命令行參數可以解決問題。
過程如下。
git pull --fail
git pull origin --fail
git pull git@github.com:ueddieu/mmix.git --it works.
It seems the Command line short cuts are lack of some user information, such as user name "git".
(which is kind of strange at the first glance.)
git push --fail
git push origin --fail
git push git@github.com:ueddieu/mmix.git master --it works.
Anyway, now I can check in code smoothly. :)
There are a few cases in which the un-visible blank character will cause
problem, but it is hard to detect since they are not visible.
One famous case is the '\t' character used by Make file, it is used to mark
the start of a command. If it is replace by blank space character, it does
not work, but you can not see the difference if you only look at the make file.
This kind of problem may get the newbies crazy.
Last week, I have encounter a similar issue, which is also caused by unnecessary
blank space.
As you may know, '\' is used as line-continuation when you have a very long line, e.g.
when you configure the class path for Java in a property file, you may have something like this.
classpath=/lib/A.jar;/lib/B.jar;\
/lib/C.jar;/lib/D.jar;\
/lib/E.jar;/lib/log4j.jar;\
/lib/F.jar;/lib/httpclient.jar;
But if you add extra blank space after the '\', then you can not get the complete
content of classpath. Because only when '\' is followed by a '\n' on Unix or '\r''\n'
on Windows, it will work as line-continuation ; otherwise, e.g '\' is followed by
' ''\n', the line is complete after the '\n', the content after that will be the start of
a new line.
Fortunately, it is easy to check this kind of extra blank space by using vi in Unix.
use command '$' to go to the end of line, if there is no extra blank space after '\',
the current position should be '\', if there are any blank space after '\', the current position
is after the '\'.
媽媽和兒子
媽媽,你最近不吃魚,變笨了吧――2009.6.2
兒子又要求錄音了。我們按著臺詞在dialog。
“……”兒子
“……,I like mangoes”媽媽
“媽媽,我昨天剛教會你,又忘了?是I like watermelon。”
“哦,媽媽現在記性不好了!”
“是你這幾天不吃魚了吧,變笨了吧。明天多吃點!”
媽媽你穿這衣服蠻可愛――2009-6-9晚
兒子挑選的故事講完了。“好,ok,我們睡覺吧!”我說。
“唉,媽媽,還沒錄音呢,我去拿mp3。”自從第一次提議給他錄音,兒子每天都要求我能做到。
……
“……,媽媽,你蠻可愛的!……”錄音正起勁,兒子突然插了一句題外話。
“什么?”我沒聽清。
“你穿這衣服蠻可愛的!”兒子賊賊的笑著又重復了一遍。“因為你的衣服象小斑馬呀!”我終于明白。
我安裝openldap時主要是參考了http://hexstar.javaeye.com/blog/271912
我遇到的一個新問題是執行ldapsearch報錯如下:
can not find libdb-4.7.so.
我的解決辦法是,建立符號鏈接/usr/lib/libdb-4.7.so, 后者指向/usr/local/BerkeleyDB/lib/libdb-4.7.so
之后沒有遇到其他問題。
凡事都有其內在原因,即使是表面上毫無道理的行為,也有其內在的原因。今天再次認識到這個
道理,還是因為今天早上和我兒子的一段插曲。
今天早上,我兒子不肯起床,在床上哭鬧,不讓他媽媽去上班,要他媽媽陪他睡覺。
他媽媽要趕班車,沒時間陪她,留我在家里。我陪他睡了一會,聊了十分鐘,才知道他是有原因
的。
昨天晚上,我和她媽媽都很累,我就說今天我們早點睡覺,和兒子一起睡好了。可是因為剛剛
回上海,有很多事情要做,最后還是忙到十點半才睡。兒子就說爸爸說謊了。當然他可能還有
其它的原因,比如想我們每天和他一起睡覺。