Просмотр исходного кода

Ticket 48342 - Prevent transaction abort if a transaction has not begun

Bug Description:  Transactions may have been aborted if they had not begun yet
due to a logic issue in dna_update_config_event. Additionally, it was possible
for an operation to fail and the transaction to not be aborted, and for the
transaction to fail to start and the delete to proceed anyway!

Fix Description:  Re-arrange and correct the logic around the transaction
in dna_update_config_event. Given this code is always called during startup, we
do not have the same be-txn issues as other areas of dna. This should fix the
transaction logic.

https://fedorahosted.org/389/ticket/48342

Author: wibrown

Review by: tbordaz (Thanks)
William Brown 9 лет назад
Родитель
Сommit
472a96b512
1 измененных файлов с 22 добавлено и 22 удалено
  1. 22 22
      ldap/servers/plugins/dna/dna.c

+ 22 - 22
ldap/servers/plugins/dna/dna.c

@@ -1603,35 +1603,35 @@ dna_update_config_event(time_t event_time, void *arg)
                     slapi_pblock_set(dna_pb, SLAPI_BACKEND, be);
                     /* We need to start transaction to avoid the deadlock */
                     rc = slapi_back_transaction_begin(dna_pb);
-                    if (rc) {
-                        slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
-                                  "dna_update_config_event: failed to start transaction\n");
-                    }
-                }
+                    if (rc == 0) {
 
-                /* First delete the existing shared config entry.  This
-                 * will allow the entry to be updated for things like
-                 * port number changes, etc. */
-                slapi_delete_internal_set_pb(pb, config_entry->shared_cfg_dn,
-                                             NULL, NULL, getPluginID(), 0);
+                        /* First delete the existing shared config entry.  This
+                         * will allow the entry to be updated for things like
+                         * port number changes, etc. */
+                        slapi_delete_internal_set_pb(pb, config_entry->shared_cfg_dn,
+                                                     NULL, NULL, getPluginID(), 0);
 
-                /* We don't care about the results */
-                slapi_delete_internal_pb(pb);
+                        /* We don't care about the results */
+                        slapi_delete_internal_pb(pb);
 
-                /* Now force the entry to be recreated */
-                dna_update_shared_config(config_entry);
+                        /* Now force the entry to be recreated */
+                        rc = dna_update_shared_config(config_entry);
 
-                if (dna_pb) {
-                    if (0 == rc) {
-                        slapi_back_transaction_commit(dna_pb);
-                    } else {
-                        if (slapi_back_transaction_abort(dna_pb) != 0) {
-                            slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM, "dna_update_config_event: failed to abort transaction!\n");
+                        if (0 == rc) {
+                            slapi_back_transaction_commit(dna_pb);
+                        } else {
+                            if (slapi_back_transaction_abort(dna_pb) != 0) {
+                                slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM, "dna_update_config_event: failed to abort transaction!\n");
+                            }
                         }
+                        slapi_pblock_destroy(dna_pb);
+                        slapi_pblock_init(pb);
+                    } else {
+                        slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+                                  "dna_update_config_event: failed to start transaction\n");
                     }
-                    slapi_pblock_destroy(dna_pb);
                 }
-                slapi_pblock_init(pb);
+
             }
 
             list = PR_NEXT_LINK(list);