C初心者がmemcached-1.4.5を追いかける。(13)

C初心者がmemcached-1.4.5を追いかける。(12)の続き
ソースはコチラにてDLしました。


getoptで受け取ったパラメータによって処理を行っている部分を追いかける。

memcached.c(4347行目あたり)

        case 'v':
            settings.verbose++;
            break;
          "v"   /* verbose */

やってきました。verboseオプション。

The art of programmingのP.318にある冗舌スイッチってやつです。

オプションにあるように

           "-v            verbose (print errors/warnings while in event loop)\n"
           "-vv           very verbose (also print client commands/reponses)\n"
           "-vvv          extremely verbose (also print internal state transitions)\n"

冗舌のレベルは3段階ありました。

vオプションをつける度に、settings.verboseをインクリメントしています。

デフォルトは0です。
memcached.c(185行目あたり)

static void settings_init(void) {
    ...
    ...
    settings.verbose = 0;


各レベルにおおじてソース中で出力(fprintf)を行っています。
memcached.c(380行目あたり)

    if (settings.verbose > 1) {
        if (init_state == conn_listening) {
            fprintf(stderr, "<%d server listening (%s)\n", sfd,
                prot_text(c->protocol));
        } else if (IS_UDP(transport)) {
            fprintf(stderr, "<%d server listening (udp)\n", sfd);
        } else if (c->protocol == negotiating_prot) {
            fprintf(stderr, "<%d new auto-negotiating client connection\n",
                    sfd);
        } else if (c->protocol == ascii_prot) {
            fprintf(stderr, "<%d new ascii client connection.\n", sfd);
        } else if (c->protocol == binary_prot) {
            fprintf(stderr, "<%d new binary client connection.\n", sfd);
        } else {
            fprintf(stderr, "<%d new unknown (%d) client connection\n",
                sfd, c->protocol);
            assert(false);
        }
    }

memcached.c(506行目あたり)

    if (settings.verbose > 1)
        fprintf(stderr, "<%d connection closed.\n", c->sfd);

memcached.c(611行目あたり)

        if (settings.verbose > 2) {
            fprintf(stderr, "%d: going from %s to %s\n",
                    c->sfd, state_text(c->state),
                    state_text(state));
        }

memcached.c(757行目あたり)

        if (settings.verbose > 1)
            fprintf(stderr, ">%d NOREPLY %s\n", c->sfd, str);

memcached.c(764行目あたり)

    if (settings.verbose > 1)
        fprintf(stderr, ">%d %s\n", c->sfd, str);

memcached.c(904行目あたり)

    if (settings.verbose > 1) {
        int ii;
        fprintf(stderr, ">%d Writing bin response:", c->sfd);
        for (ii = 0; ii < sizeof(header->bytes); ++ii) {
            if (ii % 4 == 0) {
                fprintf(stderr, "\n>%d  ", c->sfd);
            }
            fprintf(stderr, " 0x%02x", header->bytes[ii]);
        }
        fprintf(stderr, "\n");
    }

memcached.c(957行目あたり)

    if (settings.verbose > 1) {
        fprintf(stderr, ">%d Writing an error: %s\n", c->sfd, errstr);
    }

memcached.c(1008行目あたり)

    if (settings.verbose > 1) {
        int i;
        fprintf(stderr, "incr ");

        for (i = 0; i < nkey; i++) {
            fprintf(stderr, "%c", key[i]);
        }
        fprintf(stderr, " %lld, %llu, %d\n",
                (long long)req->message.body.delta,
                (long long)req->message.body.initial,
                req->message.body.expiration);
    }

memcached.c(1165行目あたり)

    if (settings.verbose > 1) {
        int ii;
        fprintf(stderr, "<%d GET ", c->sfd);
        for (ii = 0; ii < nkey; ++ii) {
            fprintf(stderr, "%c", key[ii]);
        }
        fprintf(stderr, "\n");
    }

きりが無いのでgrep結果を表示

memcached.c(185):     settings.verbose = 0;
memcached.c(380):     if (settings.verbose > 1) {
memcached.c(506):     if (settings.verbose > 1)
memcached.c(611):         if (settings.verbose > 2) {
memcached.c(757):         if (settings.verbose > 1)
memcached.c(764):     if (settings.verbose > 1)
memcached.c(904):     if (settings.verbose > 1) {
memcached.c(957):     if (settings.verbose > 1) {
memcached.c(1008):     if (settings.verbose > 1) {
memcached.c(1165):     if (settings.verbose > 1) {
memcached.c(1347):     if (settings.verbose > 1) {
memcached.c(1425):             if (settings.verbose > 1) {
memcached.c(1431):                 if (settings.verbose) {
memcached.c(1447):             if (settings.verbose > 1) {
memcached.c(1461):     if (settings.verbose) {
memcached.c(1479):             if (settings.verbose) {
memcached.c(1507):         if (settings.verbose) {
memcached.c(1569):     if (settings.verbose)
memcached.c(1591):         if (settings.verbose) {
memcached.c(1600):     if (settings.verbose) {
memcached.c(1620):         if (settings.verbose)
memcached.c(1649):     if (settings.verbose > 1) {
memcached.c(1843):     if (settings.verbose > 1) {
memcached.c(1928):     if (settings.verbose > 1) {
memcached.c(2003):     if (settings.verbose > 1) {
memcached.c(2142):             if(settings.verbose > 1) {
memcached.c(2424):     APPEND_STAT("verbosity", "%d", settings.verbose);
memcached.c(2617):                 if (settings.verbose > 1)
memcached.c(2658):     if (settings.verbose > 1)
memcached.c(2939):     settings.verbose = level > MAX_VERBOSITY_LEVEL ? MAX_VERBOSITY_LEVEL : level;
memcached.c(2954):     if (settings.verbose > 1)
memcached.c(3078):         if (settings.verbose > 1) {
memcached.c(3095):                 if (settings.verbose > 1) {
memcached.c(3103):             if (settings.verbose > 1) {
memcached.c(3122):                 if (settings.verbose) {
memcached.c(3265):                 if (settings.verbose > 0)
memcached.c(3395):                 if (settings.verbose > 0)
memcached.c(3404):         if (settings.verbose > 0)
memcached.c(3437):                     if (settings.verbose > 0)
memcached.c(3461):                 if (settings.verbose > 0)
memcached.c(3517):                         if (settings.verbose > 0)
memcached.c(3565):                     if (settings.verbose > 0)
memcached.c(3574):             if (settings.verbose > 0) {
memcached.c(3616):                     if (settings.verbose > 0)
memcached.c(3625):             if (settings.verbose > 0)
memcached.c(3638):                     if (settings.verbose > 0)
memcached.c(3649):             if (settings.verbose > 0)
memcached.c(3683):                     if (settings.verbose > 0)
memcached.c(3726):         if (settings.verbose > 0)
memcached.c(3767):         if (settings.verbose > 0)
memcached.c(3786):     if (settings.verbose > 1)
memcached.c(4348):             settings.verbose++;
memcached.c(4569):         if (daemonize(maxcore, settings.verbose) == -1) {


verboseの訳

verboseの意味 - 英和辞典 Weblio辞書
verbose

                        • -

ver・bose /vɚːbós|vəːbs/
―【形】 言葉数の多い,多弁の,くどい; 冗長な.

続きは↓
C初心者がmemcached-1.4.5を追いかける。(14){lオプション}