/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
*accepted = NULL;
status = apr_socket_accept(&csd, lr->sd, ptrans); if (status == APR_SUCCESS) {
*accepted = csd; #ifdef _OSD_POSIX
apr_os_sock_get(&sockdes, csd); if (sockdes >= FD_SETSIZE) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(02176) "new file descriptor %d is too large; you probably need " "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)",
sockdes, FD_SETSIZE);
apr_socket_close(csd); return APR_EINTR;
} #endif return APR_SUCCESS;
}
if (APR_STATUS_IS_EINTR(status)) { return status;
} /* Our old behaviour here was to continue after accept() *errors.Butthisleadsusintolotsoftroubles *becausemostoftheerrorsarequitefatal.For *example,EMFILEcanbecausedbyslowdescriptor *leaks(sayina3rdpartymodule,orlibc).It's *foolishforustocontinueafteranEMFILE.Wealso *seemtoticklekernelbugsonsomeplatformswhich *leadtonever-endingloopshere.Soitseemsbest *tojustexitinmostcases.
*/ switch (status) { #ifdefined(HPUX11) && defined(ENOBUFS) /* On HPUX 11.x, the 'ENOBUFS, No buffer space available' *erroroccursbecausetheaccept()cannotcomplete. *YouwillnotseeENOBUFSwith10.20becausethekernel *hidesanyoccurrencefrombeingreturnedtouserspace. *ENOBUFSwith11.x'sTCP/IPstackispossible,andcould *occurintermittently.Asawork-around,wearegoingto *ignoreENOBUFS.
*/ case ENOBUFS: #endif
#ifdef EPROTO /* EPROTO on certain older kernels really means *ECONNABORTED,soweneedtoignoreitforthem. *Seediscussioninnew-httpdarchivesnh.9701 *searchforEPROTO. * *Alsoseenh.9603,searchforEPROTO: *ThereispotentiallyabuginSolaris2.xx<6, *andotherboxesthatimplementtcpsocketsin *userland(i.e.ontopofSTREAMS).Onthese *systems,EPROTOcanactuallyresultinafatal *loop.SeePR#981forexample.It'shardto *handlebothusesofEPROTO.
*/ case EPROTO: #endif #ifdef ECONNABORTED case ECONNABORTED: #endif /* Linux generates the rest of these, other tcp *stacks(i.e.bsd)tendtohidethembehind *getsockopt()interfaces.Theyoccurwhen *thenetgoessourortheclientdisconnects *afterthethree-wayhandshakehasbeendone *inthekernelbutbeforeuserlandhaspicked *upthesocket.
*/ #ifdef ECONNRESET case ECONNRESET: #endif #ifdef ETIMEDOUT case ETIMEDOUT: #endif #ifdef EHOSTUNREACH case EHOSTUNREACH: #endif #ifdef ENETUNREACH case ENETUNREACH: #endif /* EAGAIN/EWOULDBLOCK can be returned on BSD-derived *TCPstackswhentheconnectionisabortedbefore *wecallconnect,butonlybecauseourlistener *socketsarenon-blocking(AP_NONBLOCK_WHEN_MULTI_LISTEN)
*/ #ifdef EAGAIN case EAGAIN: #endif #ifdef EWOULDBLOCK #if !defined(EAGAIN) || EAGAIN != EWOULDBLOCK case EWOULDBLOCK: #endif #endif break; #ifdef ENETDOWN case ENETDOWN: /* *Whenthenetworklayerhasbeenshutdown,there *isnotmuchuseinsimplyexiting:theparent *wouldsimplyre-createus(andwe'dfailagain). *UsetheCHILDFATALcodetoteartheserverdown. *@@@Martin'sideaforpossibleimprovement: *Adifferentapproachwouldbetodefine *anewAPEXIT_NETDOWNexitcode,thereception *ofwhichwouldmaketheparentshutdownall *children,thenidle-loopuntilitdetectedthat *thenetworkisupagain,andrestartthechildren. *BenHydenotedthattemporaryENETDOWNsituations *occurinmobileIP.
*/
ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(02177) "apr_socket_accept: giving up."); return APR_EGENERAL; #endif/*ENETDOWN*/
default: /* If the socket has been closed in ap_close_listeners() *bytherestart/stopaction,wemaygetEBADF. *Donotprintanerrorinthiscase.
*/ if (!lr->active) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, status, ap_server_conf, APLOGNO(02178) "apr_socket_accept failed for inactive listener"); return status;
}
ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(02179) "apr_socket_accept: (client socket)"); return APR_EGENERAL;
} return status;
}
if (!one_process) {
ap_fatal_signal_setup(ap_server_conf, pconf);
} elseif (!ap_retained_data_get("ap_unixd_mpm_one_process_cleanup")) { /* In one process mode (debug), httpd will exit immediately when asked *to(SIGTERM/SIGINT)andneverrestart.Westillwantthecleanupsto *runthough(suchthate.g.temporaryfiles/IPCsdon'tleakonthe *system),sothefirsttimearoundweuseatexit()tocleanupafter *ourselves.
*/
ap_retained_data_create("ap_unixd_mpm_one_process_cleanup", 1);
atexit(ap_terminate);
}
/* Signals' handlers depend on retained data */
(void)ap_unixd_mpm_get_retained_data();
typedefenum
{
bs2_unknown, /* not initialized yet. */
bs2_noFORK, /* no fork() because -X flag was specified */
bs2_FORK, /* only fork() because uid != 0 */
bs2_UFORK /* Normally, ufork() is used to switch identities. */
} bs2_ForkType;
static bs2_ForkType forktype = bs2_unknown;
/* Determine the method for forking off a child in such a way as to *setboththePOSIXandBS2000userid'stotheunprivilegeduser.
*/ static bs2_ForkType os_forktype(int one_process)
{ /* have we checked the OS version before? If yes return the previous *result-theOSreleaseisn'tgoingtochangesuddenly!
*/ if (forktype == bs2_unknown) { /* not initialized yet */
/* No fork if the one_process option was set */ if (one_process) {
forktype = bs2_noFORK;
} /* If the user is unprivileged, use the normal fork() only. */ elseif (getuid() != 0) {
forktype = bs2_FORK;
} else
forktype = bs2_UFORK;
} return forktype;
}
/* This routine complements the setuid() call: it causes the BS2000 job *environmenttobeswitchedtothetargetuser'suserid. *ThatisimportantifCGIscriptstrytoexecutenativeBS2000commands.
*/ int os_init_job_environment(server_rec *server, constchar *user_name, int one_process)
{
bs2_ForkType type = os_forktype(one_process);
/* We can be sure that no change to uid==0 is possible because of *thechecksinhttp_core.c:set_user()
*/
if (one_process) {
type = forktype = bs2_noFORK;
ap_log_error(APLOG_MARK, APLOG_ERR, 0, server, APLOGNO(02180) "The debug mode of Apache should only " "be started by an unprivileged user!"); return0;
}
return0;
}
/* BS2000 requires a "special" version of fork() before a setuid() call */
pid_t os_fork(constchar *user)
{
pid_t pid; char username[USER_LEN+1];
switch (os_forktype(0)) {
case bs2_FORK:
pid = fork(); break;
case bs2_UFORK:
apr_cpystrn(username, user, sizeof username);
/* Make user name all upper case - for some versions of ufork() */
ap_str_toupper(username);
pid = ufork(username); if (pid == -1 && errno == EPERM) {
ap_log_error(APLOG_MARK, APLOG_EMERG, errno, ap_server_conf,
APLOGNO(02181) "ufork: Possible mis-configuration " "for user %s - Aborting.", user); exit(1);
} break;
default:
pid = 0; break;
}
return pid;
}
#endif/* _OSD_POSIX */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.