CESNET / libnetconf

C NETCONF library
Other
113 stars 84 forks source link

rollback on error option for edit-config is not working correctly. #152

Open jashwanth opened 8 years ago

jashwanth commented 8 years ago

Hi, I observed that when the lock is held on the datastores and then edit-config operation is applied on the datastore , all the prior datastores shouldnot rollback when the return code is NCDS_RPC_NOT_APPLICABLE. So in ncds_apply_rpc2all function all the session information was lost because of rolling back and the next operations might result in a failure becuase of lock held on some datastores and some are freed from lock?

I suggest the following fix in ncds_apply_rpc2all

 /* If return code for a datastore is  NCDS_RPC_NOT_APPLICABLE then don't do
         * any rollback operation on that datastore */
        match_datastore_id = 0;

        /* Iterate till we reach the current datastore and check whether
         * rpc is applied on that datastore */
        while ((ncds.datastores_ids[match_datastore_id] != -1) &&
               (ncds.datastores_ids[match_datastore_id] != ds_rollback->datastore->id))
        {
          match_datastore_id++;
        }

        /* Since rpc was not applied on this datastore,
         * skip rollback for it */
        if (ncds.datastores_ids[match_datastore_id] == -1)
        {
          continue;
        }

continue with the code .............. if (ds_rollback->datastore->transapis != NULL && ds_rollback->datastore->tapi_callbacks_count && (op == NC_OP_COMMIT || op == NC_OP_COPYCONFIG || (op == NC_OP_EDITCONFIG && (nc_rpc_get_testopt(rpc) != NC_EDIT_TESTOPT_TEST))) && ( target == NC_DATASTORE_RUNNING)) { transapi = 1; } else { transapi = 0; }