Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F5519276
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/tests/khandle_test.c b/tests/khandle_test.c
index 4750abe9..962549e3 100644
--- a/tests/khandle_test.c
+++ b/tests/khandle_test.c
@@ -1,47 +1,52 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include "ring.h"
#include "utils.h"
-int my_action(struct knet_host *host, void *data);
+#define HOST_LIST_SIZE 8192
+#define HOST_LIST_LOOP 64
+
+struct knet_host *host_list[HOST_LIST_SIZE];
-int my_action(struct knet_host *host, void *data)
+static int my_action(struct knet_host *host, void *data)
{
host->active = 1;
+ *(size_t *) data += 1;
return 0;
}
-#define HOST_LIST_SIZE 8192
-#define HOST_LIST_LOOP 64
-
-struct knet_host *host_list[HOST_LIST_SIZE];
-
int main(int argc, char *argv[])
{
int i, j;
+ size_t loopnum;
knet_handle_t knet_h;
knet_h = knet_handle_new();
for (i = 0; i < HOST_LIST_SIZE; i++) {
host_list[i] = malloc(sizeof(struct knet_host));
knet_host_add(knet_h, host_list[i]);
}
+ loopnum = 0;
+
for (i = 0; i < HOST_LIST_SIZE; i++) {
for (j = 0; j < HOST_LIST_LOOP; j++)
- knet_host_foreach(knet_h, my_action, NULL);
+ knet_host_foreach(knet_h, my_action, &loopnum);
knet_host_remove(knet_h, host_list[i]);
}
for (i = 0; i < HOST_LIST_SIZE; i++) {
free(host_list[i]);
+ host_list[i] = NULL;
}
+ printf("loop count: %lu times\n", loopnum);
+
return 0;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Sep 5, 9:19 AM (9 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2308625
Default Alt Text
(1 KB)
Attached To
Mode
rK kronosnet
Attached
Detach File
Event Timeline
Log In to Comment