On Tue, Jul 01, 2008 at 07:01:42AM +0200, Fabio M. Di Nitto wrote:
> No. You can just install the callback and be done with it. The ccs fd was 
> never a real fd to poll.

OK, it's a cman callback.  If the ccs "connection" isn't really a
connection and if it's not necessary then can we get rid of the illusion?


> Given that this code is going to be re-implemented N times, I suggest 
> again to create a cluster/common/helpers with pre-built objects to just 
> include at linking time (note that we also share and duplicate a lot of 
> header files around and it was in my mind for sometime to create a 
> cluster/common/includes too)

Let's get the code in place and replicated first, before trying to factor
it.  And I don't think it needs to be too complicated.  Assuming I can
make my simplified logsys api work (really, we're trying to solve stuff in
parallel here that should be sequential)...


/* Read cluster.conf settings and convert them into logsys values.
   If no cluster.conf setting exists, the default that was used in
   logsys_init() is used. */

int read_ccs_logging(int *mode, int *facility, int *priority, char *file,
                     int *debug)
{
        *mode = MYPROG_DEFAULT_MODE;
        *facility = MYPROG_DEFAULT_FACILITY;
        *priority = MYPROG_DEFAULT_PRIORITY;
        strcpy(file, MYPROG_DEFAULT_FILE);

        /* Read settings from ccs to override the defaults above.
           (with some appropriate helper functions around ccs_get, the
           following can be pretty compact)

           mode from
           "/cluster/logging/@to_stderr"
           "/cluster/logging/@to_syslog"
           "/cluster/logging/@to_file"

           facility from
           "/cluster/logging/@syslog_facility"

           priority from
           "/cluster/logging/[EMAIL PROTECTED]"prog_name\"]/@syslog_level"

           file from
           "/cluster/logging/@filename"

           debug from
           "/cluster/logging/[EMAIL PROTECTED]"prog_name\"]/@debug"
        */
}

/* this function will also be called when we get a cman config-update event */

void setup_logging(int *prog_debug)
{
        int mode, facility, priority;
        char *file;

        /* The debug setting is special, it's used by the program
           and not used to configure logsys. */

        read_ccs_logging(&mode, &facility, &priority, file, prog_debug);
        logsys_conf(mode, facility, priority, file);
}

int main(int argc, char **argv)
{
        logsys_init(MYPROG_DEFAULT_MODE, MYPROG_DEFAULT_FACILITY,
                    MYPROG_DEFAULT_PRIORITY, MYPROG_DEFAULT_FILE);

        /* set up cman/ccs connections ... */

        setup_logging(&prog_debug);
}

Reply via email to