Repository: puma/puma
File: lib/puma/binder.rb (Ruby)

Code before:
            io = add_unix_listener path, umask, mode, backlog
            logger.log "* #{log_msg} on #{str}"
          end

          @listeners << [str, io]
        when "ssl"

          raise "Puma compiled without SSL support" unless HAS_SSL

          params = Util.parse_query uri.query
          ctx = MiniSSL::ContextBuilder.new(params, @events).context

          if fd = @inherited_fds.delete(str)
            logger.log "* Inherited #{str}"
            io = inherit_ssl_listener fd, ctx
          elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
            io = inherit_ssl_listener sock, ctx
            logger.log "* Activated #{str}"
          else
            ios_len = @ios.length
            io = add_ssl_listener uri.host, uri.port, ctx

            ssl_qry = str[/\?.+\z/]
            @ios[ios_len..-1].each do |i|
              addr = loc_addr_str i
              logger.log "* #{log_msg} on ssl://#{addr}#{ssl_qry}"
            end
          end

          @listeners << [str, io] if io
        else
          logger.error "Invalid URI: #{str}"
        end
      end

      # If we inherited fds but didn't use them (because of a
      # configuration change), then be sure to close them.
      @inherited_fds.each do |str, fd|
        logger.log "* Closing unused inherited connection: #{str}"

        begin
          IO.for_fd(fd).close
        rescue SystemCallError
        end

        # We have to unlink a unix socket path that's not being used
        uri = URI.parse str
        if uri.scheme == "unix"
          path = "#{uri.host}#{uri.path}"
          File.unlink path
        end

Review comment (suggestion):
Can't we use the URI object to get the query instead of the regexp?

```suggestion
              logger.log "* #{log_msg} on ssl://#{addr}?#{uri.query}"
```

Code after:
            io = add_unix_listener path, umask, mode, backlog
            logger.log "* #{log_msg} on #{str}"
          end

          @listeners << [str, io]
        when "ssl"

          raise "Puma compiled without SSL support" unless HAS_SSL

          params = Util.parse_query uri.query
          ctx = MiniSSL::ContextBuilder.new(params, @events).context

          if fd = @inherited_fds.delete(str)
            logger.log "* Inherited #{str}"
            io = inherit_ssl_listener fd, ctx
          elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
            io = inherit_ssl_listener sock, ctx
            logger.log "* Activated #{str}"
          else
            ios_len = @ios.length
            io = add_ssl_listener uri.host, uri.port, ctx

            @ios[ios_len..-1].each do |i|
              addr = loc_addr_str i
              logger.log "* #{log_msg} on ssl://#{addr}?#{uri.query}"
            end
          end

          @listeners << [str, io] if io
        else
          logger.error "Invalid URI: #{str}"
        end
      end

      # If we inherited fds but didn't use them (because of a
      # configuration change), then be sure to close them.
      @inherited_fds.each do |str, fd|
        logger.log "* Closing unused inherited connection: #{str}"

        begin
          IO.for_fd(fd).close
        rescue SystemCallError
        end

        # We have to unlink a unix socket path that's not being used
        uri = URI.parse str
        if uri.scheme == "unix"
          path = "#{uri.host}#{uri.path}"
          File.unlink path
        end
      end