# File lib/mongrel.rb, line 711
711:     def run
712:       BasicSocket.do_not_reverse_lookup=true
713: 
714:       configure_socket_options
715: 
716:       if $tcp_defer_accept_opts
717:         @socket.setsockopt(*$tcp_defer_accept_opts) rescue nil
718:       end
719: 
720:       @acceptor = Thread.new do
721:         while true
722:           begin
723:             client = @socket.accept
724: 
725:             if $tcp_cork_opts
726:               client.setsockopt(*$tcp_cork_opts) rescue nil
727:             end
728: 
729:             worker_list = @workers.list
730: 
731:             if worker_list.length >= @num_processors
732:               STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_processors max). Dropping connection."
733:               client.close rescue Object
734:               reap_dead_workers("max processors")
735:             else
736:               thread = Thread.new(client) {|c| process_client(c) }
737:               thread[:started_on] = Time.now
738:               @workers.add(thread)
739: 
740:               sleep @timeout/100 if @timeout > 0
741:             end
742:           rescue StopServer
743:             @socket.close rescue Object
744:             break
745:           rescue Errno::EMFILE
746:             reap_dead_workers("too many open files")
747:             sleep 0.5
748:           rescue Errno::ECONNABORTED
749:             # client closed the socket even before accept
750:             client.close rescue Object
751:           rescue Object => exc
752:             STDERR.puts "!!!!!! UNHANDLED EXCEPTION! #{exc}.  TELL ZED HE'S A MORON."
753:             STDERR.puts $!.backtrace.join("\n") if $mongrel_debug_client
754:           end
755:         end
756:         graceful_shutdown
757:       end
758: 
759:       return @acceptor
760:     end