Top


定義場所(file name)

hotspot/src/os/linux/vm/attachListener_linux.cpp

説明(description)

// Dequeue an operation
//
// In the Linux implementation there is only a single operation and clients
// cannot queue commands (except at the socket level).
//

名前(function name)

LinuxAttachOperation* LinuxAttachListener::dequeue() {

本体部(body)

  {- -------------------------------------------
  (1) (以下の for ループ内で, クライアントからのリクエストが届くまで待機し, 
      届いたリクエストをリターンする)
      ---------------------------------------- -}

      for (;;) {

    {- -------------------------------------------
  (1.1) (変数宣言など)
        ---------------------------------------- -}

        int s;

    {- -------------------------------------------
  (1.1) (accept() を呼んで, クライアントからコネクトされるまで待機)
        ---------------------------------------- -}

        // wait for client to connect
        struct sockaddr addr;
        socklen_t len = sizeof(addr);
        RESTARTABLE(::accept(listener(), &addr, &len), s);
        if (s == -1) {
          return NULL;      // log a warning?
        }

    {- -------------------------------------------
  (1.1) 
        ---------------------------------------- -}

        // get the credentials of the peer and check the effective uid/guid
        // - check with jeff on this.
        struct ucred cred_info;
        socklen_t optlen = sizeof(cred_info);
        if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
          int res;
          RESTARTABLE(::close(s), res);
          continue;
        }
        uid_t euid = geteuid();
        gid_t egid = getegid();

        if (cred_info.uid != euid || cred_info.gid != egid) {
          int res;
          RESTARTABLE(::close(s), res);
          continue;
        }

    {- -------------------------------------------
  (1.1) LinuxAttachListener::read_request() を呼んで
        クライアントからの通知を受信し, 届いた文字列をパースする.
        受信(&パース)に成功すれば結果をリターン.
        ---------------------------------------- -}

        // peer credential look okay so we read the request
        LinuxAttachOperation* op = read_request(s);
        if (op == NULL) {
          int res;
          RESTARTABLE(::close(s), res);
          continue;
        } else {
          return op;
        }
      }
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.