Linux利器strace(2)
4165 epoll_wait(9, {{EPOLLOUT, {u32=3081163048, u64=697886249710965032}}, {...}, 5\
12, 300000) = 2
4165 gettimeofday({1295420285, 130967}, NULL) = 0
4165 recv(16, 0xbfdd7d8b, 1, MSG_PEEK) = -1 EAGAIN (Resource temporarily unavailable)
4165 getsockopt(17, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
//--将用户http请求交给Fast-CGI
4165 writev(17, [{"\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4\0\1\3\30\0\0\21\7GATEWA"..., 832}], 1) = 832
4165 epoll_wait(9, {{EPOLLIN|EPOLLOUT, {u32=3081163048, u64=697886249710965032}}}, 512, 300000) = 1
4165 gettimeofday({1295420285, 131559}, NULL) = 0
//--接收Fast-CGI响应
4165 recv(17, "\1\6\0\1\0V\2\0X-Powered-By: PHP/5.2.10"..., 65536, 0) = 112
4165 readv(17, [{"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 65424}], 1) = 0
4165 mmap2(NULL, 274432, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7514000
4165 close(17) = 0
4165 munmap(0xb7514000, 274432) = 0
//-- 响应客户端http请求,即http响应
4165 writev(16, [{"HTTP/1.1 200 OK\r\nServer: nginx/0"..., 228}, {"22\r\n", 4}, ..., 5) = 273
4165 write(5, "116.66.34.82 - - [19/Jan/2011:14"..., 191) = 191
4165 setsockopt(16, SOL_TCP, TCP_NODELAY, [1], 4) = 0
4165 recv(16, 0x9b024e8, 32768, 0) = -1 EAGAIN (Resource temporarily unavailable)
...
通过这些,我们只能够大概地了解,Nginx这里启用了epoll。同时,还可以了解到Nginx和Fast-CGI底层是如何运作的。奇 怪,hello.php文件中有三个inclue,即加载了三次文件,这里没有看到相应的i/o逻辑操作,是为什么呢?这是因为,Nginx并没解析处理PHP脚本,而是交给Fast-CGI去做这部事情了。
#strace -f -F -o php-cgi-strace /wwwchroot/php/bin/php-cgi --fpm-config /wwwchroot/php/etc/php-fpm.conf
//--接收来自Nginx发出的请求
4510 <... accept resumed> {sa_family=AF_INET, sin_port=htons(35983), sin_addr=inet_addr("127.0.0.1")}, [16]) = 3
4510 clock_gettime(CLOCK_MONOTONIC, {22638545, 869965681}) = 0
4510 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
4510 read(3, "\1\1\0\1\0\10\0\0", 8) = 8
4510 read(3, "\0\1\0\0\0\0\0\0", 8) = 8
4510 read(3, "\1\4\0\1\0035\3\0", 8) = 8
4510 read(3, "\21\7GATEWAY_INTERFACECGI/1.1\17\5SERV"..., 824) = 824
4510 read(3, "\1\4\0\1\0\0\0\0", 8) = 8
4510 time(NULL) = 1295425149
相关新闻>>
- 发表评论
-
- 最新评论 更多>>