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
之后没有遇到其他问题。
凡事都有其内在原因,即使是表面上毫无道理的行为,也有其内在的原因。今天再次认识到这个
道理,还是因为今天早上和我儿子的一段插曲。
今天早上,我儿子不肯起床,在床上哭闹,不让他妈妈去上班,要他妈妈陪他睡觉。
他妈妈要赶班车,没时间陪她,留我在家里。我陪他睡了一会,聊了十分钟,才知道他是有原因
的。
昨天晚上,我和她妈妈都很累,我就说今天我们早点睡觉,和儿子一起睡好了。可是因为刚刚
回上海,有很多事情要做,最后还是忙到十点半才睡。儿子就说爸爸说谎了。当然他可能还有
其它的原因,比如想我们每天和他一起睡觉。