From: Jong Hyuk Choi Date: Fri, 19 Apr 2002 21:41:32 +0000 (+0000) Subject: Patch for ITS# 1643 X-Git-Tag: OPENLDAP_REL_ENG_2_MP~163 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=60b1ee1ba99e8acae83ff7348b307dbda4af6a73;p=openldap Patch for ITS# 1643 --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index d5e949b3d2..b7cc3e70ef 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -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"; diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c index f0bfd306f2..d9dccddab9 100644 --- a/servers/slapd/back-bdb/attribute.c +++ b/servers/slapd/back-bdb/attribute.c @@ -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 diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 832a6bb959..be89b98bf3 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -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" diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index d05777336e..ad1bcfe3bb 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -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 ); diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index 37e621905a..e9c40dcbbc 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -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"; diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 9c37cf835f..4905609305 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -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"; diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 037183b547..b7789a647c 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -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 diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index d3fde84883..cb5d9cce31 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -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; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index bc8fb97361..8221b8b060 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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"; diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 5d72674985..0e05443926 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -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"; diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index 8166d3da05..7899c89be7 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -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, diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 84fc36164e..6297633eb8 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -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 */