Commit 8f78c964 authored by Howard Chu's avatar Howard Chu
Browse files

Rework Modify statslog too

parent 103ff9a7
...@@ -131,36 +131,42 @@ do_modify( ...@@ -131,36 +131,42 @@ do_modify(
} }
if ( StatslogTest( LDAP_DEBUG_STATS ) ) { if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
char abuf[BUFSIZ/2], *ptr = abuf; char *ptr;
int len = 0; unsigned len = 0, alen;
Statslog( LDAP_DEBUG_STATS, "%s MOD dn=\"%s\"\n", ptr = op->o_logptr;
op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 ); ptr += snprintf( ptr, LOGBUFSIZ - (ptr - op->o_logbuf),
" MOD dn=\"%s\"\n",
op->o_req_dn.bv_val );
len = ptr - op->o_logbuf;
if ( op->orm_modlist ) {
ptr += snprintf( ptr, LOGBUFSIZ - len, " MOD attr=" );
len = ptr - op->o_logbuf;
}
for ( tmp = op->orm_modlist; tmp != NULL; tmp = tmp->sml_next ) { for ( tmp = op->orm_modlist; tmp != NULL; tmp = tmp->sml_next ) {
if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) { alen = tmp->sml_type.bv_len;
Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n", if ( alen >= 256 )
op->o_log_prefix, abuf, 0, 0, 0 ); alen = 255;
if (len + 1 + alen >= LOGBUFSIZ ) {
len = 0; if ( ldap_debug & LDAP_DEBUG_STATS )
ptr = abuf; lutil_debug( ldap_debug, LDAP_DEBUG_STATS, "%s", op->o_log_prefix );
if ( ldap_syslog & LDAP_DEBUG_STATS )
if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) { sendlog( op->o_logbuf, ptr - op->o_logbuf );
Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n", ptr = lutil_strcopy( op->o_logptr, " MOD attr=" );
op->o_log_prefix, tmp->sml_type.bv_val, 0, 0, 0 ); len = ptr - op->o_logbuf;
continue;
}
}
if (len) {
*ptr++ = ' ';
len++;
} }
ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val); ptr = lutil_strncopy( ptr, tmp->sml_type.bv_val, alen );
len += tmp->sml_type.bv_len; len += alen;
*ptr++ = ' ';
*ptr = '\0';
} }
if (len) { if ( ptr != op->o_logptr ) {
Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n", if ( ldap_debug & LDAP_DEBUG_STATS )
op->o_log_prefix, abuf, 0, 0, 0 ); lutil_debug( ldap_debug, LDAP_DEBUG_STATS, "%s", op->o_log_prefix );
if ( ldap_syslog & LDAP_DEBUG_STATS )
sendlog( op->o_logbuf, ptr - op->o_logbuf );
*op->o_logptr = '\0';
} }
} }
#endif /* LDAP_DEBUG */ #endif /* LDAP_DEBUG */
......
...@@ -156,6 +156,7 @@ sendlog(char *tbuf, int cnt) ...@@ -156,6 +156,7 @@ sendlog(char *tbuf, int cnt)
openlog(LogTag, LogStat, 0); openlog(LogTag, LogStat, 0);
connectlog(); connectlog();
#if 1
/* /*
* If the send() failed, there are two likely scenarios: * If the send() failed, there are two likely scenarios:
* 1) syslogd was restarted * 1) syslogd was restarted
...@@ -175,6 +176,7 @@ sendlog(char *tbuf, int cnt) ...@@ -175,6 +176,7 @@ sendlog(char *tbuf, int cnt)
break; break;
} while (errno == ENOBUFS); } while (errno == ENOBUFS);
} }
#endif
} }
static void static void
......
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