public NGWin32NamedPipeServerSocket()

in nailgun-server/src/main/java/com/facebook/nailgun/NGWin32NamedPipeServerSocket.java [70:110]


  public NGWin32NamedPipeServerSocket(int maxInstances, String path, boolean requireStrictLength)
      throws IOException {
    this.openHandles = new LinkedBlockingQueue<>();
    this.connectedHandles = new LinkedBlockingQueue<>();
    this.closeCallback =
        handle -> {
          if (connectedHandles.remove(handle)) {
            closeConnectedPipe(handle, false);
          }
          if (openHandles.remove(handle)) {
            closeOpenPipe(handle);
          }
        };
    this.maxInstances = maxInstances;
    this.requireStrictLength = requireStrictLength;
    if (!path.startsWith(WIN32_PIPE_PREFIX)) {
      this.path = WIN32_PIPE_PREFIX + path;
    } else {
      this.path = path;
    }
    String lockPath = this.path + "_lock";
    lockHandle =
        API.CreateNamedPipe(
            lockPath,
            NGWin32NamedPipeLibrary.FILE_FLAG_FIRST_PIPE_INSTANCE
                | NGWin32NamedPipeLibrary.PIPE_ACCESS_DUPLEX,
            0,
            1,
            BUFFER_SIZE,
            BUFFER_SIZE,
            0,
            null);
    if (lockHandle == NGWin32NamedPipeLibrary.INVALID_HANDLE_VALUE) {
      throw new IOException(
          String.format("Could not create lock for %s, error %d", lockPath, API.GetLastError()));
    } else {
      if (!API.DisconnectNamedPipe(lockHandle)) {
        throw new IOException(String.format("Could not disconnect lock %d", API.GetLastError()));
      }
    }
  }