ia64/xen-unstable

changeset 11788:5297ced4d610

[xenstore] Don't create a transaction for singleton read/write operations.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Thu Oct 12 11:26:07 2006 +0100 (2006-10-12)
parents b0ee6789e428
children d2e6a7be622d
files tools/xenstore/xenstore_client.c
line diff
     1.1 --- a/tools/xenstore/xenstore_client.c	Thu Oct 12 11:25:32 2006 +0100
     1.2 +++ b/tools/xenstore/xenstore_client.c	Thu Oct 12 11:26:07 2006 +0100
     1.3 @@ -267,12 +267,13 @@ int
     1.4  main(int argc, char **argv)
     1.5  {
     1.6      struct xs_handle *xsh;
     1.7 -    xs_transaction_t xth;
     1.8 +    xs_transaction_t xth = XBT_NULL;
     1.9      int ret = 0, socket = 0;
    1.10      int prefix = 0;
    1.11      int tidy = 0;
    1.12      int upto = 0;
    1.13      int recurse = 0;
    1.14 +    int transaction;
    1.15  
    1.16      while (1) {
    1.17  	int c, index = 0;
    1.18 @@ -339,18 +340,28 @@ main(int argc, char **argv)
    1.19      }
    1.20  #endif
    1.21  
    1.22 +#if defined(CLIENT_read)
    1.23 +    transaction = (argc - optind) > 1;
    1.24 +#elif defined(CLIENT_write)
    1.25 +    transaction = (argc - optind) > 2;
    1.26 +#else
    1.27 +    transaction = 1;
    1.28 +#endif
    1.29 +
    1.30      xsh = socket ? xs_daemon_open() : xs_domain_open();
    1.31      if (xsh == NULL)
    1.32  	err(1, socket ? "xs_daemon_open" : "xs_domain_open");
    1.33  
    1.34    again:
    1.35 -    xth = xs_transaction_start(xsh);
    1.36 -    if (xth == XBT_NULL)
    1.37 -	errx(1, "couldn't start transaction");
    1.38 +    if (transaction) {
    1.39 +	xth = xs_transaction_start(xsh);
    1.40 +	if (xth == XBT_NULL)
    1.41 +	    errx(1, "couldn't start transaction");
    1.42 +    }
    1.43  
    1.44      ret = perform(optind, argc, argv, xsh, xth, prefix, tidy, upto, recurse);
    1.45  
    1.46 -    if (!xs_transaction_end(xsh, xth, ret)) {
    1.47 +    if (transaction && !xs_transaction_end(xsh, xth, ret)) {
    1.48  	if (ret == 0 && errno == EAGAIN) {
    1.49  	    output_pos = 0;
    1.50  	    goto again;