~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to gio/gasynchelper.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
 
169
169
  return source;
170
170
}
 
171
 
 
172
#ifdef G_OS_WIN32
 
173
gboolean
 
174
_g_win32_overlap_wait_result (HANDLE           hfile,
 
175
                              OVERLAPPED      *overlap,
 
176
                              DWORD           *transferred,
 
177
                              GCancellable    *cancellable)
 
178
{
 
179
  GPollFD pollfd[2];
 
180
  gboolean result = FALSE;
 
181
  gint num, npoll;
 
182
 
 
183
  pollfd[0].fd = (gint)overlap->hEvent;
 
184
  pollfd[0].events = G_IO_IN;
 
185
  num = 1;
 
186
 
 
187
  if (g_cancellable_make_pollfd (cancellable, &pollfd[1]))
 
188
    num++;
 
189
 
 
190
loop:
 
191
  npoll = g_poll (pollfd, num, -1);
 
192
  if (npoll <= 0)
 
193
    /* error out, should never happen */
 
194
    goto end;
 
195
 
 
196
  if (g_cancellable_is_cancelled (cancellable))
 
197
    {
 
198
      /* CancelIO only cancels pending operations issued by the
 
199
       * current thread and since we're doing only sync operations,
 
200
       * this is safe.... */
 
201
      /* CancelIoEx is only Vista+. Since we have only one overlap
 
202
       * operaton on this thread, we can just use: */
 
203
      result = CancelIo (hfile);
 
204
      g_warn_if_fail (result);
 
205
    }
 
206
 
 
207
  result = GetOverlappedResult (overlap->hEvent, overlap, transferred, FALSE);
 
208
  if (result == FALSE &&
 
209
      GetLastError () == ERROR_IO_INCOMPLETE &&
 
210
      !g_cancellable_is_cancelled (cancellable))
 
211
    goto loop;
 
212
 
 
213
end:
 
214
  if (num > 1)
 
215
    g_cancellable_release_fd (cancellable);
 
216
 
 
217
  return result;
 
218
}
 
219
#endif