From cronfy at gmail.com Wed Sep 8 00:39:12 2010 From: cronfy at gmail.com (cronfy) Date: Wed, 8 Sep 2010 02:39:12 +0400 Subject: [mpm-itk] Why process connection with fork() ? Message-ID: Hello, I am interested, why connection processing is implemented via fork() in child_main(). Looks like the only reason is to write a message to log if something goes wrong with a child: /* * We now have a connection, so set it up with the appropriate * socket options, file descriptors, and read/write buffers. */ { pid_t pid = fork(), child_pid; int status; switch (pid) { case -1: ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, "fork: Unable to fork new process"); break; case 0: /* child */ apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname, pchild); current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc); if (current_conn) { ap_process_connection(current_conn, csd); ap_lingering_close(current_conn); } exit(0); default: /* parent; just wait for child to be done */ do { child_pid = waitpid(pid, &status, 0); } while (child_pid == -1 && errno == EINTR); if (child_pid != pid || !WIFEXITED(status)) { if (WIFSIGNALED(status)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "child died with signal %u", WTERMSIG(status)); } else if (WEXITSTATUS(status) != 0) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "child exited with non-zero exit status %u", WEXITSTATUS(status)); } else { ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, "waitpid() failed"); } clean_child_exit(1); } break; } } Isn't it better to just process a connection (execute case 0: block) and exit immediately, without fork()ing? With this implementation we always need 2*N + 1 processes to serve N simultaneous requests, which does not look good for performance. -- // cronfy From sgunderson at bigfoot.com Wed Sep 8 00:43:19 2010 From: sgunderson at bigfoot.com (Steinar H. Gunderson) Date: Wed, 8 Sep 2010 00:43:19 +0200 Subject: [mpm-itk] Why process connection with fork() ? In-Reply-To: References: Message-ID: <20100907224319.GB12486@samfundet.no> On Wed, Sep 08, 2010 at 02:39:12AM +0400, cronfy wrote: > I am interested, why connection processing is implemented via fork() > in child_main(). Looks like the only reason is to write a message to > log if something goes wrong with a child: The reason is that a fork is much cheaper than a full restart of the child. Also, the respawn logic (which we just copy) is not tuned at all for children dying constantly. > With this implementation we always need 2*N + 1 processes to serve N > simultaneous requests, which does not look good for performance. Sleeping processes do not cost much, unless you have an extremely bad scheduler. /* Steinar */ -- Homepage: http://www.sesse.net/ From roman at rs-labs.com Mon Sep 20 19:11:05 2010 From: roman at rs-labs.com (Roman Medina-Heigl Hernandez) Date: Mon, 20 Sep 2010 19:11:05 +0200 Subject: [mpm-itk] Mod_evasive Message-ID: <4C9795A9.5030006@rs-labs.com> Hello, Did anybody get mod_evasive to work with mpm-itk? I didn't and I suspect may be due to incompatibility with itk. Any idea? TIA. -- Saludos, -Roman PGP Fingerprint: 09BB EFCD 21ED 4E79 25FB 29E1 E47F 8A7D EAD5 6742 [Key ID: 0xEAD56742. Available at KeyServ]