<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 25, 2016 at 4:59 PM, Marc-André Lureau <span dir="ltr"><<a href="mailto:mlureau@redhat.com" target="_blank">mlureau@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5"><br>
<br>
----- Original Message -----<br>
> > + for (i = 0; i < 5; ++i)<br>
> > + {<br>
> > + if (g_cancellable_is_cancelled (cancel_map))<br>
> > + return;<br>
> > + else<br>
> > + g_usleep (loop_time);<br>
> > + }<br>
> > +<br>
><br>
> I am not sure I see the point of waiting 0.5s here. Add a comment? (a<br>
> better way would be to use g_poll with the pollfd cancellable can<br>
> creats: no need to loop)<br>
><br>
><br>
> I tryed this using g_io_channel_win32_make_pollfd(), but the way the FD<br>
> (well actually file handle) is created on windows, it doesn't support<br>
> polling.<br>
> It might require a more in depth rewrite of the windows part of webdavd to<br>
> make it work.<br>
<br>
</div></div>I mean the cancellable fd (g_cancellable_make_pollfd + g_poll), I would be surprised if this combination didn't work on windows and file a bug.<br>
<br></blockquote><div><br></div><div>Aaah you mean g_poll for the cancel_map. Yeah that would work.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also please explain the point of 0.5s delay.<br></blockquote><div><br></div><div>If sharing is disabled, read_thread will immediately return and cause the main_loop to stop.<br>This in turn causes the cancellable object to be canceled and the loop stops.<br><br>If nothing happens in that 0.5 second (no cancel is called), it means, that sharing is enabled,<br>because read_thread (and main loop) is blocked, and we can call map_drive.<br><br></div><div>This could probably be even less. I started with 5s, and downed it to 0.5s,<br>but since the actual mapping takes about 5 seconds, it wouldn't make much difference.<br></div><div><br></div><div>Anyway will change to g_cancellable_make_pollfd + g_poll.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
> > +#ifdef G_OS_WIN32<br>
> > + GCancellable * cancel_map = g_cancellable_new ();<br>
> > + GTask * map_drive_task = g_task_new (NULL, NULL, NULL, NULL);<br>
><br>
> no unref? you probably should g_task_return() somewhere too.<br>
><br>
> If I don't set the GTask to return-on-cancel, I don't need to call<br>
> g_task_return(),<br>
> because the callback is empty.<br>
><br>
> From the GTask doc:<br>
> Other than in that case, task will be completed when the GTaskThreadFunc<br>
> returns,<br>
> not when it calls a g_task_return_ function.<br>
><br>
><br>
><br>
> > + g_task_set_task_data (map_drive_task, cancel_map, NULL);<br>
> > + g_task_run_in_thread (map_drive_task, map_drive);<br>
><br>
> I think you could unref after this call, since run_in_thread() keeps a ref.<br>
><br>
> Before adding and calling map_drive, I think you should implement the<br>
> function to check if there is already a mapping.<br>
><br>
> Mapping should be always removed before starting the service.<br>
> It is removed when stopping the service, and automatically removed when<br>
> restarting Windows.<br>
><br>
<br>
</span>"always" is in the best of the worlds without any crash or force shutdown or manual intervention etc.. Please add a check before adding more drives.<br>
<br>
thanks<br>
</blockquote></div><br></div><div class="gmail_extra">Ok will add the check.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">Lukas Venhoda</div>
</div></div>