]> git.sur5r.net Git - openldap/commitdiff
Patch for ITS# 1643
authorJong Hyuk Choi <jongchoi@openldap.org>
Fri, 19 Apr 2002 21:41:32 +0000 (21:41 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Fri, 19 Apr 2002 21:41:32 +0000 (21:41 +0000)
12 files changed:
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/attribute.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/bind.c
servers/slapd/back-bdb/compare.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/referral.c
servers/slapd/back-bdb/search.c

index d5e949b3d233eee3e65adf7467ec4695a6e7f1ce..b7cc3e70ef661f6a08cb1c6d0550da567177b2fc 100644 (file)
@@ -151,6 +151,9 @@ retry:      /* transaction retry */
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
                        goto retry;
+               case LDAP_BUSY:
+                       text = "ldap server busy";
+                       goto return_results;
                default:
                        rc = LDAP_OTHER;
                        text = "internal error";
index f0bfd306f23c0c6221f912922b22ab509557a019..d9dccddab9d2217e7d43b19cb66d351624261d91 100644 (file)
@@ -89,7 +89,7 @@ bdb_attribute(
                        if( txn != NULL ) {
                                boi->boi_err = rc;
                        }
-                       return LDAP_OTHER;
+                       return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY;
                }
                if (e == NULL) {
 #ifdef NEW_LOGGING
index 832a6bb95958ad226542cf967540dd079b490f17..be89b98bf30361f5165387cc92175719c878f71b 100644 (file)
@@ -28,7 +28,9 @@ LDAP_BEGIN_DECL
 #define bv2DBT(bv,t)           ((t)->data = (bv)->bv_val, \
                                                                (t)->size = (bv)->bv_len )
 
-#define BDB_TXN_RETRIES        16
+#define BDB_TXN_RETRIES                16
+
+#define BDB_MAX_ADD_LOOP       30
 
 #ifdef BDB_SUBDIRS
 #define BDB_TMP_SUBDIR LDAP_DIRSEP "tmp"
index d05777336e1ddfb43288f1c838b971e48cbeccc4..ad1bcfe3bb8315648d2da15b9a6ec51412cce818 100644 (file)
@@ -53,6 +53,10 @@ bdb_bind(
        case DB_NOTFOUND:
        case 0:
                break;
+       case LDAP_BUSY:
+               send_ldap_result( conn, op, LDAP_BUSY,
+                       NULL, "ldap server busy", NULL, NULL );
+               return LDAP_BUSY;
        default:
                send_ldap_result( conn, op, rc=LDAP_OTHER,
                        NULL, "internal error", NULL, NULL );
index 37e621905aee2eb4409db016da9a3df8a920d67c..e9c40dcbbc4bb5b721b096f200b0a188869b359c 100644 (file)
@@ -38,6 +38,9 @@ bdb_compare(
        case DB_NOTFOUND:
        case 0:
                break;
+       case LDAP_BUSY:
+               text = "ldap server busy";
+               goto return_results;
        default:
                rc = LDAP_OTHER;
                text = "internal error";
index 9c37cf835f1298c8453f0a3143839ee9bdda74ab..49056093050b2d00ef31026069f8c5f735e54ace 100644 (file)
@@ -119,6 +119,9 @@ retry:      /* transaction retry */
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
                        goto retry;
+               case LDAP_BUSY:
+                       text = "ldap server busy";
+                       goto return_results;
                default:
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -231,6 +234,9 @@ retry:      /* transaction retry */
        case DB_LOCK_DEADLOCK:
        case DB_LOCK_NOTGRANTED:
                goto retry;
+       case LDAP_BUSY:
+               text = "ldap server busy";
+               goto return_results;
        default:
                rc = LDAP_OTHER;
                text = "internal error";
index 037183b547afcbddcfae18fba86bcc8c0f049db8..b7789a647c971cc194d0ec12578fee8d69477539 100644 (file)
@@ -121,14 +121,24 @@ int bdb_id2entry_rw(
                ch_free( data.data );
        }
 
-       if (rc == 0 && bdb_cache_add_entry_rw(&bdb->bi_cache, *e, rw) != 0) {
-               if ((*e)->e_private != NULL)
+       while (rc == 0 && bdb_cache_add_entry_rw(&bdb->bi_cache, *e, rw) != 0) {
+               Entry *ee;
+               int add_loop_cnt = 0;
+               if ( (*e)->e_private != NULL ) {
                        free ((*e)->e_private);
+               }
                (*e)->e_private = NULL;
-               bdb_entry_return (*e);
-               if ((*e=bdb_cache_find_entry_id(&bdb->bi_cache,id,rw)) != NULL) {
+               if ( (ee = bdb_cache_find_entry_id
+                               (&bdb->bi_cache, id, rw) ) != NULL) {
+                       bdb_entry_return ( *e );
+                       *e = ee;
                        return 0;
                }
+               if ( ++add_loop_cnt == BDB_MAX_ADD_LOOP ) {
+                       bdb_entry_return ( *e );
+                       *e = NULL;
+                       return LDAP_BUSY;
+               }
        }
 
 #ifdef BDB_HIER
index d3fde84883d9ce42989e7bfaad5f27228c80a9c2..cb5d9cce3137c63b6898c3e56b4f7b0fc6b396d7 100644 (file)
@@ -318,6 +318,9 @@ retry:      /* transaction retry */
                        goto retry;
                case DB_NOTFOUND:
                        break;
+               case LDAP_BUSY:
+                       text = "ldap server busy";
+                       goto return_results;
                default:
                        rc = LDAP_OTHER;
                }
index bc8fb973616c3cc6923ab3eaa09e6beca2baf204..8221b8b0608aa715a151b28e99cacbf02d46251a 100644 (file)
@@ -133,6 +133,9 @@ retry:      /* transaction retry */
        case DB_LOCK_DEADLOCK:
        case DB_LOCK_NOTGRANTED:
                goto retry;
+       case LDAP_BUSY:
+               text = "ldap server busy";
+               goto return_results;
        default:
                rc = LDAP_OTHER;
                text = "internal error";
@@ -204,6 +207,9 @@ retry:      /* transaction retry */
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
                        goto retry;
+               case LDAP_BUSY:
+                       text = "ldap server busy";
+                       goto return_results;
                default:
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -350,6 +356,9 @@ retry:      /* transaction retry */
                        case DB_LOCK_DEADLOCK:
                        case DB_LOCK_NOTGRANTED:
                                goto retry;
+                       case LDAP_BUSY:
+                               text = "ldap server busy";
+                               goto return_results;
                        default:
                                rc = LDAP_OTHER;
                                text = "internal error";
index 5d72674985eb34e3301e5bb27d007a1198bf270b..0e05443926b91970ecebf9e9b951c6c76ed4cb32 100644 (file)
@@ -159,6 +159,9 @@ retry:      /* transaction retry */
        case DB_NOTFOUND:
        case 0:
                break;
+       case LDAP_BUSY:
+               *text = "ldap server busy";
+               goto done;
        default:
                rc = LDAP_OTHER;
                *text = "internal error";
index 8166d3da05688f276f9f56a61e1ea54eb098727a..7899c89be71f32b2ab7e8afe3b7baeab92abd4fb 100644 (file)
@@ -43,6 +43,16 @@ bdb_referrals(
                rc = 0;
        case 0:
                break;
+       case LDAP_BUSY:
+               if (e != NULL) {
+                       bdb_cache_return_entry_r(&bdb->bi_cache, e);
+               }
+               if (matched != NULL) {
+                       bdb_cache_return_entry_r(&bdb->bi_cache, matched);
+               }
+               send_ldap_result( conn, op, LDAP_BUSY,
+                       NULL, "ldap server busy", NULL, NULL );
+               return LDAP_BUSY;
        default:
 #ifdef NEW_LOGGING
                LDAP_LOG (( "referral", LDAP_LEVEL_ERR,
index 84fc36164e262c88017588db28514282d9a874d6..6297633eb87e173669b9778f3b1cc4dd843e3dc4 100644 (file)
@@ -88,6 +88,16 @@ bdb_search(
        case DB_NOTFOUND:
        case 0:
                break;
+       case LDAP_BUSY:
+               if (e != NULL) {
+                       bdb_cache_return_entry_r(&bdb->bi_cache, e);
+               }
+               if (matched != NULL) {
+                       bdb_cache_return_entry_r(&bdb->bi_cache, matched);
+               }
+               send_ldap_result( conn, op, LDAP_BUSY,
+                       NULL, "ldap server busy", NULL, NULL );
+               return LDAP_BUSY;
        default:
                if (e != NULL) {
                        bdb_cache_return_entry_r(&bdb->bi_cache, e);
@@ -313,6 +323,12 @@ bdb_search(
                /* get the entry with reader lock */
                rc = bdb_id2entry_r( be, NULL, id, &e );
 
+               if (rc == LDAP_BUSY) {
+                       send_ldap_result( conn, op, rc=LDAP_BUSY,
+                               NULL, "ldap server busy", NULL, NULL );
+                       goto done;
+               }
+
                if ( e == NULL ) {
                        if( !BDB_IDL_IS_RANGE(candidates) ) {
                                /* only complain for non-range IDLs */