まずは、libev のインストール
[192.168.162.128] cvs -z3 -d :pserver:anonymous@cvs.schmorp.de/schmorpforge co libev [192.168.162.128] cd libev [192.168.162.128] autoheader [192.168.162.128] aclocal [192.168.162.128] autoconf [192.168.162.128] touch ltmain.sh [192.168.162.128] automake -a [192.168.162.128] ./configure --prefix=$HOME/local [192.168.162.128] rm libtool [192.168.162.128] ln -s /usr/bin/libtool libtool [192.168.162.128] make [192.168.162.128] make installlibtool がうまく動かなかったので置き換え lighttz の方では、以下のように Makefile を書き換えて gmake
[192.168.162.128] cat Makefile
lighttz: lighttz.o
gcc -o lighttz ./lighttz.o -L$$HOME/local/lib -lev -u is_default_loop
lighttz.o: lighttz.c
gcc -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"lighttz.d" -MT"lighttz.d" -I../libev -o $@ ./lighttz.c
clean:
rm -f lighttz.o lighttz
start:
LD_LIBRARY_PATH=/home/sikaku/local/lib/ ./lighttz &
起動してみる。
[192.168.162.128] LD_LIBRARY_PATH=/home/sikaku/local/lib/ ./lighttz & [192.168.162.128] curl http://localhost:8002/ curl: (18) transfer closed with 1 bytes remaining to readどうやら、1byte 書き出しが少ないようだ。Hello World Hello World
[192.168.162.128]
以下のように修正するとうまくいく
Index: lighttz.c
===================================================================
--- lighttz.c (revision 103)
+++ lighttz.c (working copy)
@@ -76,7 +76,7 @@
char superjared[]="HTTP/1.1 200 OK\r\nContent-Length: 336\r\nConnection: close\r\nContent-Type: text/html\r\nDate: Sat, 26 Apr 2008 01:13:35 GMT\r\nServer: lighttz/0.1\r\n\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" version=\"-//W3C//DTD XHTML 1.1//EN\" xml:lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><title>Hello World</title></head><body><p>Hello World</p></body></html>";
if (revents & EV_WRITE){
- write(cli->fd,superjared,strlen(superjared));
+ write(cli->fd,superjared,strlen(superjared)+1);
ev_io_stop(EV_A_ w);
}
close(cli->fd);
No comments:
Post a Comment