Fixed a problem with change callback registration
authorIngo Huerner <ingo.huerner@xse.de>
Thu, 14 Nov 2013 16:23:55 +0000 (17:23 +0100)
committerIngo Huerner <ingo.huerner@xse.de>
Thu, 14 Nov 2013 16:23:55 +0000 (17:23 +0100)
include/persistence_client_library_file.h
src/persistence_client_library_db_access.c
src/persistence_client_library_dbus_service.c

index 0df35c4..5f26eef 100644 (file)
@@ -184,7 +184,7 @@ int pclFileWriteData(int fd, const void * buffer, int buffer_size);
  * @param path the path to the file
  * @param size the size of the path
  *
- * @note the allocated memory for the path string will be freed in tpclFileReleasePath
+ * @note the allocated memory for the path string will be freed in pclFileReleasePath
  *
  * @return positive value on success, which must be used when pclFileReleasePath will be called
  * On error a negative value will be returned with th follwoing error codes:
index 2f6aec7..9932548 100644 (file)
@@ -616,7 +616,7 @@ int persistence_notify_on_change(char* key, unsigned int ldbid, unsigned int use
       gRegNotifySeatNo = seat_no;
       gRegNotifyPolicy = regPolicy;
 
-      if(regPolicy == Notify_lastEntry)
+      if(regPolicy == Notify_register)
       {
          // assign callback
          gChangeNotifyCallback = callback;
index deaa397..aade4d3 100644 (file)
@@ -161,8 +161,14 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec
                notifyStruct.seat_no     = atoi(seat_no);
 
                // call the registered callback function
-               gChangeNotifyCallback(&notifyStruct);
-
+               if(gChangeNotifyCallback != NULL )
+               {
+                  gChangeNotifyCallback(&notifyStruct);
+               }
+               else
+               {
+                  DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback => gChangeNotifyCallback is not set (possibly NULL)") );
+               }
                result = DBUS_HANDLER_RESULT_HANDLED;
             }
             dbus_connection_flush(connection);
@@ -205,7 +211,6 @@ static DBusHandlerResult handleObjectPathMessageFallback(DBusConnection * connec
          DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("handleObjectPathMessageFallback -> not a signal:"), DLT_STRING(dbus_message_get_member(message)) );
       }
    }
-
    return result;
 }