Hateburo: kazeburo hatenablog

Operations Engineer / Site Reliability / 運用系小姑 / Perl Monger

Starletとmod_perlの違い

straceで見てると、acceptしてからリクエスト行を読むまでの処理が違う


Starlet

23:40:11.099510 accept(4, {sa_family=AF_INET, sin_port=htons(44565), sin_addr=inet_addr("10.xxx.xx.xx")}, [1562186129334075408]) = 5
23:40:11.269991 ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffdfb20930) = -1 EINVAL (Invalid argument)
23:40:11.270040 lseek(5, 0, SEEK_CUR)   = -1 ESPIPE (Illegal seek)
23:40:11.270067 ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffdfb20930) = -1 EINVAL (Invalid argument)
23:40:11.270090 lseek(5, 0, SEEK_CUR)   = -1 ESPIPE (Illegal seek)
23:40:11.270112 fcntl(5, F_SETFD, FD_CLOEXEC) = 0
23:40:11.270158 fcntl(5, F_GETFL)       = 0x2 (flags O_RDWR)
23:40:11.270179 fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK) = 0
23:40:11.270213 setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
23:40:11.270254 getpeername(5, {sa_family=AF_INET, sin_port=htons(44565), sin_addr=inet_addr("10.xxx.xx.xx")}, [16118978554984661008]) = 0
23:40:11.270668 rt_sigprocmask(SIG_BLOCK, [TERM], [], 8) = 0
23:40:11.270701 rt_sigaction(SIGTERM, {SIG_DFL, [], SA_RESTORER, 0x3440c302d0}, {SIG_DFL, [], SA_RESTORER, 0x3440c302d0}, 8) = 0
23:40:11.270740 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
23:40:11.270793 rt_sigprocmask(SIG_BLOCK, [TERM], [], 8) = 0
23:40:11.270820 rt_sigaction(SIGTERM, {0x45fa80, [], SA_RESTORER, 0x3440c302d0}, {SIG_DFL, [], SA_RESTORER, 0x3440c302d0}, 8) = 0
23:40:11.270849 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
23:40:11.271183 read(5, "GET /...................................................x HTTP/1.1\r\nHost: 10.xxx.xx.xx:5000\r\nAccept: */*\r\n"..., 131072) = 545

mod_perl

09:56:54.832697 accept(17, {sa_family=AF_INET, sin_port=htons(57142), sin_addr=inet_addr("10.xxx.xx.xxx")}, [16]) = 3
09:56:56.878100 rt_sigaction(SIGUSR1, {0x1, [], SA_RESTORER|SA_INTERRUPT, 0x3440c302d0}, {0x455570, [], SA_RESTORER|SA_INTERRUPT, 0x3440c302d0}, 8) = 0
09:56:56.878150 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
09:56:56.878172 getsockname(3, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("10.xxx.xx.xxx")}, [16]) = 0
09:56:56.878203 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
09:56:56.878247 read(3, "POST /.................... HTTP/1.0\r\nHost: 10.xxx.xx.6xx:8080\r\nUser-Agent: ............."..., 4096) = 1448


Starletのacceptのあとのlseekはファイルハンドルがシーカボーかどうか確認するために行うものらしい。そしてrt_sig*はlocal $SIG{TERM}があるため。

参考 http://www.perlmonks.org/bare/?node_id=607509