Misc cleanup

This commit is contained in:
Kurt Zeilenga 2002-09-16 21:50:55 +00:00
parent f0364e25d1
commit 3eb21d8a6c
3 changed files with 43 additions and 48 deletions

View File

@ -501,26 +501,25 @@ long connection_init(
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0; c->c_is_udp = 0;
if (tls_udp_option == 2) if( tls_udp_option == 2 ) {
{
c->c_is_udp = 1; c->c_is_udp = 1;
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug, ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_PROVIDER, (void*)"udp_" ); LBER_SBIOD_LEVEL_PROVIDER, (void*)"udp_" );
#endif #endif
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_udp, ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_udp,
LBER_SBIOD_LEVEL_PROVIDER, (void *)&s ); LBER_SBIOD_LEVEL_PROVIDER, (void *)&s );
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_readahead, ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_readahead,
LBER_SBIOD_LEVEL_PROVIDER, NULL ); LBER_SBIOD_LEVEL_PROVIDER, NULL );
} else } else
#endif #endif
{ {
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug, ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_PROVIDER, (void*)"tcp_" ); LBER_SBIOD_LEVEL_PROVIDER, (void*)"tcp_" );
#endif #endif
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_tcp, ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_tcp,
LBER_SBIOD_LEVEL_PROVIDER, (void *)&s ); LBER_SBIOD_LEVEL_PROVIDER, (void *)&s );
} }
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
@ -1307,8 +1306,9 @@ connection_input(
char *cdn = NULL; char *cdn = NULL;
#endif #endif
if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc()) if ( conn->c_currentber == NULL &&
== NULL ) { ( conn->c_currentber = ber_alloc()) == NULL )
{
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, ERR, LDAP_LOG( CONNECTION, ERR,
"connection_input: conn %lu ber_alloc failed.\n", "connection_input: conn %lu ber_alloc failed.\n",
@ -1322,8 +1322,7 @@ connection_input(
errno = 0; errno = 0;
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp) if ( conn->c_is_udp ) {
{
char peername[sizeof("IP=255.255.255.255:65336")]; char peername[sizeof("IP=255.255.255.255:65336")];
len = ber_int_sb_read(conn->c_sb, &peeraddr, len = ber_int_sb_read(conn->c_sb, &peeraddr,
sizeof(struct sockaddr)); sizeof(struct sockaddr));
@ -1396,12 +1395,12 @@ connection_input(
} }
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp) { if( conn->c_is_udp ) {
if (tag == LBER_OCTETSTRING) { if( tag == LBER_OCTETSTRING ) {
ber_get_stringa( ber, &cdn ); ber_get_stringa( ber, &cdn );
tag = ber_peek_tag(ber, &len); tag = ber_peek_tag(ber, &len);
} }
if (tag != LDAP_REQ_ABANDON && tag != LDAP_REQ_SEARCH) { if( tag != LDAP_REQ_ABANDON && tag != LDAP_REQ_SEARCH ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, ERR, LDAP_LOG( CONNECTION, ERR,
"connection_input: conn %lu invalid req for UDP 0x%lx.\n", "connection_input: conn %lu invalid req for UDP 0x%lx.\n",
@ -1427,7 +1426,7 @@ connection_input(
op->o_pagedresults_state = conn->c_pagedresults_state; op->o_pagedresults_state = conn->c_pagedresults_state;
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
op->o_peeraddr = peeraddr; op->o_peeraddr = peeraddr;
if (cdn) { if (cdn ) {
ber_str2bv( cdn, 0, 1, &op->o_dn ); ber_str2bv( cdn, 0, 1, &op->o_dn );
op->o_protocol = LDAP_VERSION2; op->o_protocol = LDAP_VERSION2;
} }

View File

@ -676,8 +676,7 @@ static int slap_open_listener(
continue; continue;
} }
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (l.sl_is_udp) if( l.sl_is_udp ) socktype = SOCK_DGRAM;
socktype = SOCK_DGRAM;
#endif #endif
l.sl_sd = socket( (*sal)->sa_family, socktype, 0); l.sl_sd = socket( (*sal)->sa_family, socktype, 0);
if ( l.sl_sd == AC_SOCKET_INVALID ) { if ( l.sl_sd == AC_SOCKET_INVALID ) {
@ -1063,8 +1062,7 @@ slapd_daemon_task(
* listening port. The listen() and accept() calls * listening port. The listen() and accept() calls
* are unnecessary. * are unnecessary.
*/ */
if ( slap_listeners[l]->sl_is_udp ) if ( slap_listeners[l]->sl_is_udp ) {
{
slapd_add( slap_listeners[l]->sl_sd ); slapd_add( slap_listeners[l]->sl_sd );
continue; continue;
} }
@ -1349,14 +1347,12 @@ slapd_daemon_task(
continue; continue;
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if ( slap_listeners[l]->sl_is_udp ) if ( slap_listeners[l]->sl_is_udp ) {
{ /* The first time we receive a query, we set this
/* The first time we receive a query, we set this * up as a "connection". It remains open for the life
* up as a "connection". It remains open for the life * of the slapd.
* of the slapd. */
*/ if ( slap_listeners[l]->sl_is_udp < 2 ) {
if ( slap_listeners[l]->sl_is_udp < 2 )
{
id = connection_init( id = connection_init(
slap_listeners[l]->sl_sd, slap_listeners[l]->sl_sd,
slap_listeners[l]->sl_url, "", "", slap_listeners[l]->sl_url, "", "",
@ -1665,8 +1661,7 @@ slapd_daemon_task(
/* The listener is the data port. Don't /* The listener is the data port. Don't
* skip it. * skip it.
*/ */
if (slap_listeners[l]->sl_is_udp) if (slap_listeners[l]->sl_is_udp) continue;
continue;
#endif #endif
is_listener = 1; is_listener = 1;
break; break;
@ -1717,8 +1712,7 @@ slapd_daemon_task(
for ( l = 0; slap_listeners[l] != NULL; l++ ) { for ( l = 0; slap_listeners[l] != NULL; l++ ) {
if ( i == slap_listeners[l]->sl_sd ) { if ( i == slap_listeners[l]->sl_sd ) {
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (slap_listeners[l]->sl_is_udp) if (slap_listeners[l]->sl_is_udp) continue;
continue;
#endif #endif
is_listener = 1; is_listener = 1;
break; break;
@ -1769,8 +1763,7 @@ slapd_daemon_task(
for ( l = 0; slap_listeners[l] != NULL; l++ ) { for ( l = 0; slap_listeners[l] != NULL; l++ ) {
if ( rd == slap_listeners[l]->sl_sd ) { if ( rd == slap_listeners[l]->sl_sd ) {
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (slap_listeners[l]->sl_is_udp) if (slap_listeners[l]->sl_is_udp) continue;
continue;
#endif #endif
is_listener = 1; is_listener = 1;
break; break;

View File

@ -250,8 +250,9 @@ send_ldap_response(
} }
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp) { if( conn->c_is_udp ) {
rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0); rc = ber_write(ber,
(char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
if (rc != sizeof(struct sockaddr)) { if (rc != sizeof(struct sockaddr)) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR, LDAP_LOG( OPERATION, ERR,
@ -709,17 +710,18 @@ send_search_entry(
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp) { if (conn->c_is_udp) {
rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0); rc = ber_write(ber,
(char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
if (rc != sizeof(struct sockaddr)) { if (rc != sizeof(struct sockaddr)) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR, LDAP_LOG( OPERATION, ERR,
"send_search_entry: conn %lu ber_printf failed\n", "send_search_entry: conn %lu ber_printf failed\n",
conn ? conn->c_connid : 0, 0, 0 ); conn ? conn->c_connid : 0, 0, 0 );
#else #else
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 ); Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
#endif #endif
ber_free_buf( ber ); ber_free_buf( ber );
return( 1 ); return( 1 );
} }
} }
if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) { if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
@ -1125,8 +1127,9 @@ send_search_entry(
} }
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1) if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1) {
rc = ber_printf( ber, "}" ); rc = ber_printf( ber, "}" );
}
#endif #endif
if ( rc == -1 ) { if ( rc == -1 ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING