Top


定義場所(file name)

hotspot/src/os/solaris/vm/attachListener_solaris.cpp

説明(description)

// This is door function which the client executes via a door_call.
extern "C" {

名前(function name)

  static void enqueue_proc(void* cookie, char* argp, size_t arg_size,
                           door_desc_t* dt, uint_t n_desc)
  {

本体部(body)

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

        int return_fd = -1;
        SolarisAttachOperation* op = NULL;

  {- -------------------------------------------
  (1) まだ初期化されていなければ, 残りの処理は行わない.
      (コメントでは, そもそもそういうケースでここにたどり着くのか?, とも書かれているが...)
      ---------------------------------------- -}

        // no listener
        jint res = 0;
        if (!AttachListener::is_initialized()) {
          // how did we get here?
          debug_only(warning("door_call when not enabled"));
          res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
        }

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

        // check client credentials
        if (res == 0) {
          if (check_credentials() != 0) {
            res = (jint)SolarisAttachListener::ATTACH_ERROR_DENIED;
          }
        }

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

        // if we are stopped at ShowMessageBoxOnError then maybe we can
        // load a diagnostic library
        if (res == 0 && is_error_reported()) {
          if (ShowMessageBoxOnError) {
            // TBD - support loading of diagnostic library here
          }

          // can't enqueue operation after fatal error
          res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
        }

  {- -------------------------------------------
  (1) 以上の処理でエラーがなければ, 
      create_operation() を呼んで
      クライアントから送られてきた argp 引数の文字列をパースする.
      ---------------------------------------- -}

        // create the operation
        if (res == 0) {
          int err;
          op = create_operation(argp, arg_size, &err);
          res = (op == NULL) ? (jint)err : 0;
        }

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

        // create a pair of connected sockets. Store the file descriptor
        // for one end in the operation and enqueue the operation. The
        // file descriptor for the other end wil be returned to the client.
        if (res == 0) {
          int s[2];
          if (socketpair(PF_UNIX, SOCK_STREAM, 0, s) < 0) {
            delete op;
            res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
          } else {
            op->set_socket(s[0]);
            return_fd = s[1];
            SolarisAttachListener::enqueue(op);
          }
        }

  {- -------------------------------------------
  (1) door_return() で, クライアントに結果を通知.
      ---------------------------------------- -}

        // Return 0 (success) + file descriptor, or non-0 (error)
        if (res == 0) {
          door_desc_t desc;
          desc.d_attributes = DOOR_DESCRIPTOR;
          desc.d_data.d_desc.d_descriptor = return_fd;
          door_return((char*)&res, sizeof(res), &desc, 1);
        } else {
          door_return((char*)&res, sizeof(res), NULL, 0);
        }
      }
    }

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