X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fdaemon.c;h=2893a905f90c1f05de7eb85f2332dd0cd2605439;hb=b94a77687075b0eb2d54d087b8b956d197c1023c;hp=a4e3124ed9d713be777ddddecca43a706127a20b;hpb=5c8fd8bf11030c783aedf2bb86a51edd31a954a9;p=openldap diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index a4e3124ed9..2893a905f9 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2005 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -978,8 +978,14 @@ static int slap_open_listener( #endif #ifdef LDAP_PF_LOCAL case AF_LOCAL: - addrlen = sizeof(struct sockaddr_un); - break; +#ifdef LOCAL_CREDS + { + int one = 1; + setsockopt(l.sl_sd, 0, LOCAL_CREDS, &one, sizeof one); + } +#endif + addrlen = sizeof(struct sockaddr_un); + break; #endif } @@ -1666,7 +1672,7 @@ slapd_daemon_task( } ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); - if ( cat != NULL ) { + if ( cat && cat->tv_sec ) { time_t diff = difftime( cat->tv_sec, now ); if ( diff == 0 ) diff = tdelta; @@ -1714,10 +1720,12 @@ slapd_daemon_task( case 0: /* timeout - let threads run */ ebadf = 0; +#ifndef HAVE_YIELDING_SELECT Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n", 0, 0, 0 ); ldap_pvt_thread_yield(); +#endif continue; default: /* something happened - deal with it */ @@ -1729,19 +1737,16 @@ slapd_daemon_task( /* FALL THRU */ } - /* We don't need to examine the event status for wake_sds; - * if waking is set and we woke up, we'll read whatever - * we can. - */ - if ( waking ) { +#if SLAP_EVENTS_ARE_INDEXED + if ( SLAP_EVENT_IS_READ( wake_sds[0] )) { char c[BUFSIZ]; tcp_read( wake_sds[0], c, sizeof(c) ); waking = 0; ns--; + SLAP_EVENT_CLR_READ( wake_sds[0] ); continue; } -#if SLAP_EVENTS_ARE_INDEXED /* The event slot equals the descriptor number - this is * true for Unix select and poll. We treat Windows select * like this too, even though it's a kludge. @@ -1773,7 +1778,9 @@ slapd_daemon_task( /* bypass the following tests if no descriptors left */ if ( ns <= 0 ) { +#ifndef HAVE_YIELDING_SELECT ldap_pvt_thread_yield(); +#endif continue; } @@ -1847,6 +1854,7 @@ slapd_daemon_task( } slapd_close( wd ); } + SLAP_EVENT_CLR_WRITE( wd ); } for ( i = 0; nrfds > 0; i++ ) @@ -1883,12 +1891,23 @@ slapd_daemon_task( * all other connections last (as we do for select), we would need * to use multiple event handles and cascade them. * - * That seems like a bit of hassle. So the wake_sds check has moved - * above. For epoll and kqueue we can associate arbitrary data with + * That seems like a bit of hassle. So the wake_sds check has been + * skipped. For epoll and kqueue we can associate arbitrary data with * an event, so we could use pointers to the listener structure * instead of just the file descriptor. For /dev/poll we have to * search the listeners array for a matching descriptor. */ + /* if waking is set and we woke up, we'll read whatever + * we can. + */ + if ( waking ) { + char c[BUFSIZ]; + tcp_read( wake_sds[0], c, sizeof(c) ); + waking = 0; + ns--; + continue; + } + #ifdef LDAP_DEBUG Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 ); @@ -1957,7 +1976,9 @@ slapd_daemon_task( } #endif /* SLAP_EVENTS_ARE_INDEXED */ +#ifndef HAVE_YIELDING_SELECT ldap_pvt_thread_yield(); +#endif } if( slapd_shutdown == 1 ) {