Commit ae268711 authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Quanah Gibson-Mount
Browse files

ITS#6949 Allow for fd 0

parent a40243d9
...@@ -39,7 +39,7 @@ ldap_pvt_thread_mutex_t logfile_mutex; ...@@ -39,7 +39,7 @@ ldap_pvt_thread_mutex_t logfile_mutex;
static off_t logfile_fsize; static off_t logfile_fsize;
static time_t logfile_fcreated; static time_t logfile_fcreated;
static int logfile_fd; static int logfile_fd = -1;
static char logpaths[2][MAXPATHLEN]; static char logpaths[2][MAXPATHLEN];
static int logpathlen; static int logpathlen;
...@@ -69,7 +69,7 @@ slap_debug_print( const char *data ) ...@@ -69,7 +69,7 @@ slap_debug_print( const char *data )
iov[1].iov_len = strlen( data ); iov[1].iov_len = strlen( data );
if ( !logfile_only ) if ( !logfile_only )
writev( 2, iov, 2 ); writev( 2, iov, 2 );
if ( logfile_fd ) { if ( logfile_fd >= 0 ) {
int len = iov[0].iov_len + iov[1].iov_len; int len = iov[0].iov_len + iov[1].iov_len;
if ( logfile_fslimit || logfile_age ) { if ( logfile_fslimit || logfile_age ) {
ldap_pvt_thread_mutex_lock( &logfile_mutex ); ldap_pvt_thread_mutex_lock( &logfile_mutex );
...@@ -79,6 +79,7 @@ slap_debug_print( const char *data ) ...@@ -79,6 +79,7 @@ slap_debug_print( const char *data )
rotate |= 2; rotate |= 2;
if ( rotate ) { if ( rotate ) {
close( logfile_fd ); close( logfile_fd );
logfile_fd = -1;
strcpy( logpaths[0]+logpathlen, ".tmp" ); strcpy( logpaths[0]+logpathlen, ".tmp" );
rename( logfile_path, logpaths[0] ); rename( logfile_path, logpaths[0] );
logfile_open( logfile_path ); logfile_open( logfile_path );
...@@ -105,9 +106,9 @@ slap_debug_print( const char *data ) ...@@ -105,9 +106,9 @@ slap_debug_print( const char *data )
void void
logfile_close() logfile_close()
{ {
if ( logfile_fd ) { if ( logfile_fd >= 0 ) {
close( logfile_fd ); close( logfile_fd );
logfile_fd = 0; logfile_fd = -1;
} }
logfile_path[0] = '\0'; logfile_path[0] = '\0';
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment