2008-02-01から1ヶ月間の記事一覧

echod_epoll.c

レベルトリガとして使用。まあ、高速なpoll(2)ですね。 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> #include <sys/types.h> #include <unistd.h> #include <sys/epoll.h> #include <errno.h> #define ECHO_PORT 7 #define MAX_BACKLOG 5 #define RCVBUFSIZE 256 #define MAX_EV…</errno.h></sys/epoll.h></unistd.h></sys/types.h></arpa/inet.h></sys/socket.h></string.h></stdlib.h></stdio.h>

libevent: Patches for Cygwin

http://monkeymail.org/archives/libevent-users/2007-June/000685.html

echod_libevent.c

意外と苦戦。ドキュメントないなー。 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <event.h> #define ECHO_PORT 7 #define MAX_BACKLOG 5 #define RCVBUFSIZE 256 #define MAX…</event.h></errno.h></fcntl.h></unistd.h></sys/types.h></arpa/inet.h></sys/socket.h></string.h></stdlib.h></stdio.h>

UNIXドメインソケットでdRuby

http://pub.cozmixng.org/~the-rwiki/rw-cgi.rb?cmd=view;name=dRubyTut%3A%3Adrbunix おー、UNIXドメインソケットでもdRubyできるんだ。 Railsのデバッグ用に使ってみよう。

動的にPoundの動作を変更する

WEB

Poundは再起動なしに設定の再読み込みできないからApacheの方がイイ!。。。と思ってたけれど、サービスのenable/disableくらいは再起動なしにできることに気がついた。 poundctl Usage: ./poundctl -c /control/socket cmd where cmd is one of: -L n - ena…

Poundの振り分けアルゴリズム

Sessionディレクティブでバックエンドの振り分けルールを指定しないときのアルゴリズムが気になったので調べてみる。 svc.c 516行目あたり /* * Find the right back-end for a request */ BACKEND * get_backend(SERVICE *const svc, const struct in_addr …

Poundの振り分けアルゴリズム その2

DynScaleディレクティブを1にセットしておくと、動的に優先度を変えてくれるらしい。 svc.c 1034行目あたり /* * Rescale back-end priorities if needed * runs every 5 minutes */ static void do_rescale(void) { ... sq_average /= n; average /= n; sq_…

Poundの振り分けアルゴリズムをラウンドロビンに変更してみる

すごい適当なパッチ。 設定ファイルで制御するようにすればマシになるかも。 diff -up Pound-2.3.2.orig/config.c Pound-2.3.2/config.c --- Pound-2.3.2.orig/config.c 2007-05-18 17:34:53.000000000 +0900 +++ Pound-2.3.2/config.c 2008-02-11 13:40:41.…

PoundでProxyPassディレクティブみたいなことをやる

requestとheaders[0]を書き換えて「/」を「/local/」にディスパッチ。 つーか、置換やってくれる正規表現ライブラリが欲しいなぁ。 --- http.c.orig 2008-02-11 15:00:11.203125000 +0900 +++ http.c 2008-02-11 15:30:22.859375000 +0900 @@ -436,6 +436,17…

4GB USBメモリ

2,500円で売っていたので思わず購入。 安くなったなぁ。。。

ヨルムンガンド

軍事知識とかリアルっぽくて面白かった。 はやく続刊でないかな。ヨルムンガンド 1 (サンデーGXコミックス)作者: 高橋慶太郎出版社/メーカー: 小学館発売日: 2006/11/17メディア: コミック購入: 7人 クリック: 134回この商品を含むブログ (183件) を見る

Visual Studio 2008 Standard Edition

Amazonで購入。 何がうれしいってSubversionと連携できるのがうれしい。Visual Studio 2008 Standard Edition出版社/メーカー: マイクロソフト発売日: 2008/02/08メディア: DVD-ROM購入: 7人 クリック: 40回この商品を含むブログ (18件) を見る

fastladder

http://code.google.com/p/fastladder/ びっくりした。早速、コードリーディング。元のPerlのコードとどのくらいパフォーマンスが違うかきになるなぁ。 すごく面白い試みだけど、なんとなくNetscapeの姿がちらつく。。。

単体と配列とポインタ

http://www.apsis.ch/pound/ 昼休みにPoundのソースを読んでいる。ApacheやRubyに比べると圧倒的にコンパクトかつきれいなコードなので、大変読みやすい(設計の善し悪しは僕には分からない)。それはさておき、svc.cの1375行目あたりにthr_controlというリ…

フィルタと継続

Apacheのフィルタのようにストリームに対してフィルタリングを行う場合、継続がすご〜く有効なんじゃないかと思って、このところ悶々と考え込んでいる。 既存のフィルタのデータ読み出し部をハックして、データがなくなったら継続で抜ける→新しいデータがき…

制御構文単位のブロック?

制御構文の中でのスコープってないのかなぁ? irb(main):001:0> prefix NameError: undefined local variable or method `prefix' for main:Object from (irb):1 irb(main):002:0> if true irb(main):003:1> else irb(main):004:1* prefix = '' irb(main):00…

鬼車メモ

すこし触ってみる。 onig_searchとonig_matchの違い onig_searchはパターンに一致する部分を検索 onig_matchは指定したオフセットからの文字列がパターンにマッチするかを調べる 1文字目がマッチしなかったら失敗。前方検索みたいなイメージ? 「/g」はない…

鬼車: 回してみる

#include <stdio.h> #include <string.h> #include <malloc.h> #include "oniguruma.h" static regex_t *reg_compile(const char *pattern) { regex_t* reg; OnigErrorInfo einfo; int r; r = onig_new(&reg, (UChar *) pattern, (UChar *) (pattern + strlen(pattern)), ONIG_OPTION_DEFA</malloc.h></string.h></stdio.h>…

APLOG_NOERRNO

/* APLOG_NOERRNO is ignored and should not be used. It will be * removed in a future release of Apache. */ #define APLOG_NOERRNO (APLOG_LEVELMASK + 1) なるほどなるほど。

mod_digikoつくった

http://storehouse.quickvps.net/aozora/cards/000148/files/752_14964.html 文字列置換はめんどくさいなぁ… 設定 LoadModule digiko_module /usr/lib/apache2/modules/mod_digiko.so <Location /aozora> SetOutputFilter DIGIKO ProxyPass http://www.aozora.gr.jp ProxyPassR</location>…

Apache 2.0 Filters

http://www.apache.org/~gregames/ap2filters.ppt

utf82ascii

ソースコードのマルチバイト文字がUTF-8だと、VCでコンパイルできないので作成。 #include <stdio.h> #define NATIVE(c) ((~(c) & 0x80) == 0x80) #define UTF8_2BYTES(c) ((~(c) & 0x20) == 0x20) #define UTF8_3BYTES(c) ((~(c) & 0x10) == 0x10) #define UTF8_4BYT</stdio.h>…