~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to init/conf.h

  • Committer: Scott James Remnant
  • Date: 2007-06-10 15:49:13 UTC
  • Revision ID: scott@netsplit.com-20070610154913-uymy8eiihn2trg0l
* init/conf.c (conf_reload_path): It turns out that the flag trick
doesn't work for items since we often reparse them within the same
file tag (it works with files because they're atomic and reparsed).
Store the old items in a different list instead.
(conf_source_free): We need to be careful about freeing sources,
so have a function to do it properly.
(conf_item_new): Since the flag member isn't useful, don't bother
setting it.
* init/conf.h: Add conf_source_free prototype.
(ConfFile): Remove flag member.
* init/tests/test_conf.c (test_source_reload): Add test for inotify
create detection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 *
71
71
 * Normally inotify is used to watch the source for changes and load them
72
72
 * automatically, however mandatory reloading is also supported; for this
73
 
 * the @flag member is toggled, and copied to all files and items reloaded;
 
73
 * the @flag member is toggled, and copied to all files reloaded;
74
74
 * any that are in the old state are deleted.
75
75
 **/
76
76
typedef struct conf_source {
98
98
 * The @flag member is used to support mandatory reloading; when the file is
99
99
 * created and parsed, it is set to the same value as the source's.  Then
100
100
 * the source can trivially see which files have been lost, since they have
101
 
 * the wrong flag value.  We use the same method for the @items list.
 
101
 * the wrong flag value.
102
102
 **/
103
103
typedef struct conf_file {
104
104
        NihList  entry;
112
112
 * ConfItem:
113
113
 * @entry: list header,
114
114
 * @type: item type,
115
 
 * @flag: reload flag,
116
115
 * @data: pointer to actual item.
117
116
 *
118
117
 * This structure represents an item defined within a configuration file,
119
118
 * the @data pointer points to the actual item structure itself.
120
 
 *
121
 
 * The @flag member is used to support mandatory reloading; when the item
122
 
 * is first created, or reparsed, it is set to the same value as the file's.
123
 
 * Then the file can trivially see which items defined within it have been
124
 
 * lost, since they have the wrong flag value.
125
119
 **/
126
120
typedef struct conf_item {
127
121
        NihList       entry;
128
122
        ConfItemType  type;
129
123
 
130
 
        int           flag;
131
124
        union {
132
125
                void *data;
133
126
                Job  *job;
154
147
int         conf_source_reload (ConfSource *source)
155
148
        __attribute__ ((warn_unused_result));
156
149
 
 
150
int         conf_source_free   (ConfSource *source);
157
151
int         conf_file_free     (ConfFile *file);
158
152
int         conf_item_free     (ConfItem *item);
159
153