[1924] in Moira

home help back first fref pref prev next nref lref last post

Re: dcm patch

daemon@ATHENA.MIT.EDU (Jonathon Weiss)
Sun Jan 20 17:58:11 2002

Message-Id: <200201202258.RAA26160@bearing-an-hourglass.mit.edu>
From: Jonathon Weiss <jweiss@MIT.EDU>
To: Garry Zacheiss <zacheiss@MIT.EDU>
cc: moiradev@MIT.EDU
In-reply-to: Your message of "Fri, 18 Jan 2002 18:50:24 EST."
             <200201182350.SAA25205@sweet-transvestite.mit.edu> 
Date: Sun, 20 Jan 2002 17:58:07 -0500


> +  while (++arg - argv < argc)
> +    {
> +      if (**arg == '-')
> +	{
> +	  if (argis("f", "force"))
> +	    force++;
> +	  else
> +	    {
> +	      com_err(whoami, 0, "Usage: %s [-f] servicename", argv[0]);
> +	      exit(1);
> +	    }
> +	}
> +    }
> +
>    /* if services were specified on the command line, do just those ones */
>    if (argc > 1)
>      {
>        for (i = 1; i < argc; i++)
>  	{
> -	  if (generate_service(argv[i], 1))
> +	  if (argv[i][0] == '-')
> +	    continue;
> +	  if (generate_service(argv[i], force))
>  	    do_hosts(argv[i]);
>  	}
>        exit(0);

The pointer arithmatic in the control section of the while loop makes
my brain hurt.  It also seems like it is a gratuitously different
structure than that of the for loop that appears right below it.  Was
there a reason for using this particular structure?

Also, since you didn't change the "if (argc > 1)" test, /moira/bin/dcm
-f will force dcms for zero services.  While this is arguably a
command that will never get run, the behavior is a little
counter-intuitive.

> +  /* Someone might try to run a DCM from the command line while the
> +   * regular one is running, which will bypass the "interval" test.
> +   * Check inprogress to make sure they don't stomp on themselves.
> +   */
> +  if (inprogress == 1)
> +    {
> +      com_err(whoami, 0, "DCM for service `%s' already in progress", name);
> +      EXEC SQL COMMIT RELEASE;
> +      return 0;
> +    }

There's a race condition here, but I don't know how to get rid of it
completely.  We could shorten it by adding an additional select, but
that's probably not worth the effort.  Likewise with the period of
time between generating the config files and starting to update the
hosts.  I assume this is at least part of why you indicated that
people are still supposed to check for running dcms before starting
one by hand.  Some of this should probably be acknowledged in comments
in the code.

	Jonathon

home help back first fref pref prev next nref lref last post