debuggers.hg
changeset 10907:c471b326b75e
Add a transaction_started field in xenstored connection structure instead of
browsing the list of transaction each time
Bump the default to 10, and make it configurable through the command line.
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
browsing the list of transaction each time
Bump the default to 10, and make it configurable through the command line.
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author | vhanquez@gwig.uk.xensource.com |
---|---|
date | Mon Jul 31 09:30:36 2006 +0000 (2006-07-31) |
parents | d2bf1a7cc131 |
children | 2d2ed4d9b1c1 |
files | tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_transaction.c |
line diff
1.1 --- a/tools/xenstore/xenstored_core.c Sat Jul 29 14:05:59 2006 +0100 1.2 +++ b/tools/xenstore/xenstored_core.c Mon Jul 31 09:30:36 2006 +0000 1.3 @@ -80,6 +80,7 @@ static void check_store(void); 1.4 int quota_nb_entry_per_domain = 1000; 1.5 int quota_nb_watch_per_domain = 128; 1.6 int quota_max_entry_size = 2048; /* 2K */ 1.7 +int quota_max_transaction = 10; 1.8 1.9 #ifdef TESTING 1.10 static bool failtest = false; 1.11 @@ -1342,6 +1343,7 @@ struct connection *new_connection(connwr 1.12 new->write = write; 1.13 new->read = read; 1.14 new->can_write = true; 1.15 + new->transaction_started = 0; 1.16 INIT_LIST_HEAD(&new->out_list); 1.17 INIT_LIST_HEAD(&new->watches); 1.18 INIT_LIST_HEAD(&new->transaction_list); 1.19 @@ -1739,6 +1741,7 @@ static void usage(void) 1.20 " --entry-nb <nb> limit the number of entries per domain,\n" 1.21 " --entry-size <size> limit the size of entry per domain, and\n" 1.22 " --entry-watch <nb> limit the number of watches per domain,\n" 1.23 +" --transaction <nb> limit the number of transaction allowed per domain,\n" 1.24 " --no-recovery to request that no recovery should be attempted when\n" 1.25 " the store is corrupted (debug only),\n" 1.26 " --preserve-local to request that /local is preserved on start-up,\n" 1.27 @@ -1755,6 +1758,7 @@ static struct option options[] = { 1.28 { "output-pid", 0, NULL, 'P' }, 1.29 { "entry-size", 1, NULL, 'S' }, 1.30 { "trace-file", 1, NULL, 'T' }, 1.31 + { "transaction", 1, NULL, 't' }, 1.32 { "no-recovery", 0, NULL, 'R' }, 1.33 { "preserve-local", 0, NULL, 'L' }, 1.34 { "verbose", 0, NULL, 'V' }, 1.35 @@ -1774,7 +1778,7 @@ int main(int argc, char *argv[]) 1.36 const char *pidfile = NULL; 1.37 int evtchn_fd = -1; 1.38 1.39 - while ((opt = getopt_long(argc, argv, "DE:F:HNPS:T:RLVW:", options, 1.40 + while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options, 1.41 NULL)) != -1) { 1.42 switch (opt) { 1.43 case 'D': 1.44 @@ -1804,6 +1808,9 @@ int main(int argc, char *argv[]) 1.45 case 'S': 1.46 quota_max_entry_size = strtol(optarg, NULL, 10); 1.47 break; 1.48 + case 't': 1.49 + quota_max_transaction = strtol(optarg, NULL, 10); 1.50 + break; 1.51 case 'T': 1.52 tracefile = optarg; 1.53 break;
2.1 --- a/tools/xenstore/xenstored_core.h Sat Jul 29 14:05:59 2006 +0100 2.2 +++ b/tools/xenstore/xenstored_core.h Mon Jul 31 09:30:36 2006 +0000 2.3 @@ -79,6 +79,7 @@ struct connection 2.4 /* List of in-progress transactions. */ 2.5 struct list_head transaction_list; 2.6 uint32_t next_transaction_id; 2.7 + unsigned int transaction_started; 2.8 2.9 /* The domain I'm associated with, if any. */ 2.10 struct domain *domain;
3.1 --- a/tools/xenstore/xenstored_transaction.c Sat Jul 29 14:05:59 2006 +0100 3.2 +++ b/tools/xenstore/xenstored_transaction.c Mon Jul 31 09:30:36 2006 +0000 3.3 @@ -66,6 +66,7 @@ struct transaction 3.4 struct list_head changes; 3.5 }; 3.6 3.7 +extern int quota_max_transaction; 3.8 static unsigned int generation; 3.9 3.10 /* Return tdb context to use for this connection. */ 3.11 @@ -125,7 +126,6 @@ void do_transaction_start(struct connect 3.12 { 3.13 struct transaction *trans, *exists; 3.14 char id_str[20]; 3.15 - int started; 3.16 3.17 /* We don't support nested transactions. */ 3.18 if (conn->transaction) { 3.19 @@ -133,11 +133,7 @@ void do_transaction_start(struct connect 3.20 return; 3.21 } 3.22 3.23 - started = 0; 3.24 - list_for_each_entry(trans, &conn->transaction_list, list) 3.25 - started++; 3.26 - 3.27 - if (started > 5) { 3.28 + if (conn->transaction_started > quota_max_transaction) { 3.29 send_error(conn, ENOSPC); 3.30 return; 3.31 } 3.32 @@ -166,6 +162,7 @@ void do_transaction_start(struct connect 3.33 list_add_tail(&trans->list, &conn->transaction_list); 3.34 talloc_steal(conn, trans); 3.35 talloc_set_destructor(trans, destroy_transaction); 3.36 + conn->transaction_started++; 3.37 3.38 sprintf(id_str, "%u", trans->id); 3.39 send_reply(conn, XS_TRANSACTION_START, id_str, strlen(id_str)+1); 3.40 @@ -188,6 +185,7 @@ void do_transaction_end(struct connectio 3.41 3.42 conn->transaction = NULL; 3.43 list_del(&trans->list); 3.44 + conn->transaction_started--; 3.45 3.46 /* Attach transaction to arg for auto-cleanup */ 3.47 talloc_steal(arg, trans);