aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/xenstored_watch.c
diff options
context:
space:
mode:
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>2006-04-13 16:21:13 +0000
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>2006-04-13 16:21:13 +0000
commite43071c7b1a81fe80595bb6a42214d1029e8a88d (patch)
treeb9a1b215f0a8ced8902dfd5a214a2ba2cbd34a8f /tools/xenstore/xenstored_watch.c
parent9f15c912a7ef65c4a6452ca9338fccc85a8f6170 (diff)
downloadxen-e43071c7b1a81fe80595bb6a42214d1029e8a88d.tar.gz
xen-e43071c7b1a81fe80595bb6a42214d1029e8a88d.tar.bz2
xen-e43071c7b1a81fe80595bb6a42214d1029e8a88d.zip
add quota to xenstored.
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
Diffstat (limited to 'tools/xenstore/xenstored_watch.c')
-rw-r--r--tools/xenstore/xenstored_watch.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/xenstore/xenstored_watch.c b/tools/xenstore/xenstored_watch.c
index 6f3c2e4e03..3de6e7ace8 100644
--- a/tools/xenstore/xenstored_watch.c
+++ b/tools/xenstore/xenstored_watch.c
@@ -32,6 +32,8 @@
#include "xenstored_test.h"
#include "xenstored_domain.h"
+extern int quota_nb_watch_per_domain;
+
struct watch
{
/* Watches on this connection */
@@ -135,6 +137,11 @@ void do_watch(struct connection *conn, struct buffered_data *in)
}
}
+ if (domain_watch(conn) > quota_nb_watch_per_domain) {
+ send_error(conn, E2BIG);
+ return;
+ }
+
watch = talloc(conn, struct watch);
watch->node = talloc_strdup(watch, vec[0]);
watch->token = talloc_strdup(watch, vec[1]);
@@ -145,6 +152,7 @@ void do_watch(struct connection *conn, struct buffered_data *in)
INIT_LIST_HEAD(&watch->events);
+ domain_watch_inc(conn);
list_add_tail(&watch->list, &conn->watches);
trace_create(watch, "watch");
talloc_set_destructor(watch, destroy_watch);
@@ -169,6 +177,7 @@ void do_unwatch(struct connection *conn, struct buffered_data *in)
if (streq(watch->node, node) && streq(watch->token, vec[1])) {
list_del(&watch->list);
talloc_free(watch);
+ domain_watch_dec(conn);
send_ack(conn, XS_UNWATCH);
return;
}