[netfilter-cvslog] r6320 - branches/ulog/ulogd2/src

laforge at netfilter.org laforge at netfilter.org
Wed Dec 14 16:29:43 CET 2005


Author: laforge at netfilter.org
Date: 2005-12-14 16:29:42 +0100 (Wed, 14 Dec 2005)
New Revision: 6320

Modified:
   branches/ulog/ulogd2/src/ulogd.c
Log:
add cleanup of dynamically allocated memory at end of plugin stack traversal


Modified: branches/ulog/ulogd2/src/ulogd.c
===================================================================
--- branches/ulog/ulogd2/src/ulogd.c	2005-12-14 15:29:21 UTC (rev 6319)
+++ branches/ulog/ulogd2/src/ulogd.c	2005-12-14 15:29:42 UTC (rev 6320)
@@ -236,6 +236,34 @@
 	}
 }
 
+/* clean results (set all values to 0 and free pointers) */
+static void ulogd_clean_results(struct ulogd_pluginstance *pi)
+{
+	struct ulogd_pluginstance *cur;
+
+	DEBUGP("cleaning up results\n");
+
+	/* iterate through plugin stack */
+	llist_for_each_entry(cur, &pi->stack->list, list) {
+		int i;
+		
+		/* iterate through input keys of pluginstance */
+		for (i = 0; i < cur->output.num_keys; i++) {
+			struct ulogd_key *key = &cur->output.keys[i];
+
+			if (!(key->flags & ULOGD_RETF_VALID))
+				continue;
+
+			if (key->flags & ULOGD_RETF_FREE) {
+				free(key->u.value.ptr);
+				key->u.value.ptr = NULL;
+			}
+			memset(&key->u.value, 0, sizeof(key->u.value));
+			key->flags &= ~ULOGD_RETF_VALID;
+		}
+	}
+}
+
 /* propagate results to all downstream plugins in the stack */
 void ulogd_propagate_results(struct ulogd_pluginstance *pi)
 {
@@ -252,7 +280,7 @@
 			/* fallthrough */
 		case ULOGD_IRET_STOP:
 			/* we shall abort further iteration of the stack */
-			return;
+			break;
 		case ULOGD_IRET_OK:
 			/* we shall continue travelling down the stack */
 			continue;
@@ -263,24 +291,9 @@
 			break;
 		}
 	}
-}
 
-#if 0
-/* clean results (set all values to 0 and free pointers) */
-static void clean_results(struct ulogd_iret *ret)
-{
-	struct ulogd_iret *r;
-
-	for (r = ret; r; r = r->next) {
-		if (r->flags & ULOGD_RETF_FREE) {
-			free(r->value.ptr);
-			r->value.ptr = NULL;
-		}
-		memset(&r->value, 0, sizeof(r->value));
-		r->flags &= ~ULOGD_RETF_VALID;
-	}
+	ulogd_clean_results(pi);
 }
-#endif
 
 static struct ulogd_pluginstance *
 pluginstance_alloc_init(struct ulogd_plugin *pl, char *pi_id,




More information about the netfilter-cvslog mailing list