]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix bug in DataHub where it would skip the first record in a set when a filter is...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Nov 2010 20:22:18 +0000 (20:22 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Nov 2010 20:22:18 +0000 (20:22 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11008 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.c

index dad529bd38bf7f936ebfb0fa429ccd54d8b5a81b..e4dfa29d69f0b5a9b497b5a38ada9cf30dcbf32f 100644 (file)
@@ -286,85 +286,96 @@ DataHubGetNextRecord (
   DATA_HUB_INSTANCE       *Private;\r
   DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
   UINT64                  ClassFilter;\r
   DATA_HUB_INSTANCE       *Private;\r
   DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
   UINT64                  ClassFilter;\r
-  UINT64                  FilterMonotonicCount;\r
 \r
   Private               = DATA_HUB_INSTANCE_FROM_THIS (This);\r
 \r
   FilterDriver          = NULL;\r
 \r
   Private               = DATA_HUB_INSTANCE_FROM_THIS (This);\r
 \r
   FilterDriver          = NULL;\r
-  FilterMonotonicCount  = 0;\r
   ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
     EFI_DATA_RECORD_CLASS_ERROR |\r
     EFI_DATA_RECORD_CLASS_DATA |\r
     EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
 \r
   ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
     EFI_DATA_RECORD_CLASS_ERROR |\r
     EFI_DATA_RECORD_CLASS_DATA |\r
     EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
 \r
-  if (FilterDriverEvent != NULL) {\r
-    //\r
-    // For events the beginning is the last unread record. This info is\r
-    // stored in the instance structure, so we must look up the event\r
-    // to get the data.\r
-    //\r
-    FilterDriver = FindFilterDriverByEvent (\r
-                    &Private->FilterDriverListHead,\r
-                    *FilterDriverEvent\r
-                    );\r
-    if (FilterDriver == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
+  //\r
+  // If FilterDriverEvent is NULL, then return the next record\r
+  //\r
+  if (FilterDriverEvent == NULL) {\r
+    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+    if (*Record == NULL) {\r
+      return EFI_NOT_FOUND;\r
     }\r
     }\r
-    //\r
-    // Use the Class filter the event was created with.\r
-    //\r
-    ClassFilter = FilterDriver->ClassFilter;\r
+    return EFI_SUCCESS;\r
+  }\r
+    \r
+  //\r
+  // For events the beginning is the last unread record. This info is\r
+  // stored in the instance structure, so we must look up the event\r
+  // to get the data.\r
+  //\r
+  FilterDriver = FindFilterDriverByEvent (\r
+                  &Private->FilterDriverListHead,\r
+                  *FilterDriverEvent\r
+                  );\r
+  if (FilterDriver == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Use the Class filter the event was created with.\r
+  //\r
+  ClassFilter = FilterDriver->ClassFilter;\r
 \r
 \r
-    if (*MonotonicCount == 0) {\r
+  //\r
+  // Retrieve the next record or the first record.\r
+  //   \r
+  if (*MonotonicCount != 0 || FilterDriver->GetNextMonotonicCount == 0) { \r
+    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+    if (*Record == NULL) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+    \r
+    if (*MonotonicCount != 0) {\r
       //\r
       //\r
-      // Use the MTC from the Filter Driver.\r
+      // If this was not the last record then update the count associated with the filter \r
       //\r
       //\r
-      FilterMonotonicCount = FilterDriver->GetNextMonotonicCount;\r
-       \r
+      FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+    } else {\r
       //\r
       //\r
-      // The GetNextMonotonicCount field remembers the last value from the previous time.\r
-      // But we already processed this vaule, so we need to find the next one.\r
+      // Save the MonotonicCount of the last record which has been read\r
       //\r
       //\r
-      *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, &FilterMonotonicCount);\r
-      if (FilterMonotonicCount != 0) {\r
-        *MonotonicCount = FilterMonotonicCount;\r
-      }\r
-      \r
-      if ((FilterDriver->GetNextMonotonicCount != 0) && (FilterMonotonicCount == 0)) {\r
-        //\r
-        // If there is no new record to get exit now.\r
-        //\r
-        *MonotonicCount = 0;\r
-        return EFI_NOT_FOUND;\r
-      }\r
+      FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
     }\r
     }\r
+    return EFI_SUCCESS;\r
   }\r
   }\r
+  \r
   //\r
   //\r
-  // Return the record\r
+  // This is a request to read the first record that has not been read yet.  \r
+  // Set MonotoicCount to the last record successfuly read\r
+  //\r
+  *MonotonicCount = FilterDriver->GetNextMonotonicCount;\r
+  \r
+  //\r
+  // Retrieve the last record successfuly read again, but do not return it since\r
+  // it has already been returned before.\r
   //\r
   *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
   if (*Record == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
   //\r
   *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
   if (*Record == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
-\r
-  if (FilterDriver != NULL) {\r
+  \r
+  if (*MonotonicCount != 0) {\r
     //\r
     //\r
-    // If we have a filter driver update the records that have been read.\r
-    // If MonotonicCount is zero No more reacords left.\r
+    // Update the count associated with the filter \r
     //\r
     //\r
-    if (*MonotonicCount == 0) {\r
-      //\r
-      // Save the current Record MonotonicCount.\r
-      //\r
-      FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
-    } else {\r
-      //\r
-      // Point to next undread record\r
-      //\r
-      FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+    FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+\r
+    //\r
+    // Retrieve the record after the last record successfuly read \r
+    //  \r
+    *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+    if (*Record == NULL) {\r
+      return EFI_NOT_FOUND;\r
     }\r
   }\r
     }\r
   }\r
-\r
+  \r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r