[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [help] problem with watch_pipe in xenstore
Hi all, In src/tools/xenstore/xs.c : get_handle(), it says /* Watch pipe is allocated on demand in xs_fileno(). */ h->watch_pipe[0] = h->watch_pipe[1] = -1;
but in xs_fileno() function: 137-int xs_fileno(struct xs_handle *h)
138{
139 char c = 0;
140
141 mutex_lock(&h->watch_mutex);
142
143 if ((h->watch_pipe[0] == -1) && (pipe(h->watch_pipe) != -1)) {
144 /* Kick things off if the watch list is already non-empty. */
145 if (!list_empty(&h->watch_list))
146 while (write(h->watch_pipe[1], &c, 1) != 1)
147 continue;
148 }
149
150 mutex_unlock(&h->watch_mutex);
151
152 return h->watch_pipe[0];
153} When did it assign value to watch_pipe[0] and what does watch_pipe[0] and watch_pipe[1] stands for respectively? In addition, the two lines `while (read(h->watch_pipe[0], &c, 1) != 1)` and `while (write(h->watch_pipe[1], &c, 1) != 1)` appears many times,
it's odd that why always writing to watch_pipe[1] but nobody read from it and why always reading from watch_pipe[0] but nobody write to it? Grep found no answer and it's difficult to search for the trivial question by goole!
_______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |