]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/request.c
Import ITS#3578 fix from HEAD
[openldap] / libraries / libldap / request.c
index 711572c6929cdaaaafd3a26d2e9d37cc7165634f..a87fe405142b1a8058bec0c17fdb915bc14bc6ee 100644 (file)
@@ -1,14 +1,21 @@
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/*  Portions
- *  Copyright (c) 1995 Regents of the University of Michigan.
- *  All rights reserved.
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
  */
-/*---
- * This notice applies to changes, created by or for Novell, Inc.,
+/* This notice applies to changes, created by or for Novell, Inc.,
  * to preexisting works for which notices appear elsewhere in this file.
  *
  * Copyright (C) 1999, 2000 Novell, Inc. All Rights Reserved.
@@ -25,8 +32,8 @@
  * Modification to OpenLDAP source by Novell, Inc.
  * April 2000 sfs  Added code to chase V3 referrals
  *  request.c - sending of ldap requests; handling of referrals
- */
-/* Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License 
+ *---
+ * Note: A verbatim copy of version 2.0.1 of the OpenLDAP Public License 
  * can be found in the file "build/LICENSE-2.0.1" in this distribution
  * of OpenLDAP Software.
  */
@@ -269,7 +276,7 @@ ldap_send_server_request(
                        ++parentreq->lr_outrefcnt;
                }
                lr->lr_origid = parentreq->lr_origid;
-               lr->lr_parentcnt = parentreq->lr_parentcnt + 1;
+               lr->lr_parentcnt = ++parentreq->lr_parentcnt;
                lr->lr_parent = parentreq;
                lr->lr_refnext = parentreq->lr_child;
                parentreq->lr_child = lr;
@@ -441,20 +448,28 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
  */
 {
        LDAPConn        *lc;
-       LDAPURLDesc     *ls;
+       LDAPURLDesc     *lcu, *lsu;
+       int lcu_port, lsu_port;
 
        for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
-               for ( ls = srv; ls != NULL; ls = ls->lud_next ) {
-                       if ( lc->lconn_server->lud_host != NULL &&
-                               *lc->lconn_server->lud_host != '\0' &&
-                           ls->lud_host != NULL && *ls->lud_host != '\0' &&
-                               strcasecmp( ls->lud_host, lc->lconn_server->lud_host ) == 0
-                           && ls->lud_port == lc->lconn_server->lud_port ) {
+               lcu = lc->lconn_server;
+               lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme,
+                       lcu->lud_port );
+
+               for ( lsu = srv; lsu != NULL; lsu = lsu->lud_next ) {
+                       lsu_port = ldap_pvt_url_scheme_port( lsu->lud_scheme,
+                               lsu->lud_port );
+
+                       if ( strcmp( lcu->lud_scheme, lsu->lud_scheme ) == 0
+                               && lcu->lud_host != NULL && *lcu->lud_host != '\0'
+                           && lsu->lud_host != NULL && *lsu->lud_host != '\0'
+                               && strcasecmp( lsu->lud_host, lcu->lud_host ) == 0
+                           && lsu_port == lcu_port )
+                       {
                                return lc;
                        }
-                       if ( !any ) {
-                               break;
-                       }
+
+                       if ( !any ) break;
                }
        }