~ubuntu-branches/ubuntu/karmic/libxcb/karmic

« back to all changes in this revision

Viewing changes to src/xcb_conn.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-05-29 14:58:44 UTC
  • mfrom: (1.1.4 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090529145844-k4iq1ewu0qy7z0ot
Tags: 1.3-2
* Revert the libxcb-randr SONAME bump, which was accidental.
* Add symbols files for all libraries, to help us catch ABI changes.
* Use debhelper 7 and get rid of cdbs, reducing build time by a lot.
* Tighten the glob in *.install files to catch SONAME changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <unistd.h>
32
32
#include <stdlib.h>
33
33
#include <netinet/in.h>
34
 
#include <sys/select.h>
35
34
#include <fcntl.h>
36
35
#include <errno.h>
37
36
 
38
37
#include "xcb.h"
39
38
#include "xcbint.h"
 
39
#if USE_POLL
 
40
#include <poll.h>
 
41
#else
 
42
#include <sys/select.h>
 
43
#endif
40
44
 
41
45
typedef struct {
42
46
    uint8_t  status;
258
262
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count)
259
263
{
260
264
    int ret;
 
265
#if USE_POLL
 
266
    struct pollfd fd;
 
267
#else
261
268
    fd_set rfds, wfds;
 
269
#endif
262
270
 
263
271
    /* If the thing I should be doing is already being done, wait for it. */
264
272
    if(count ? c->out.writing : c->in.reading)
267
275
        return 1;
268
276
    }
269
277
 
 
278
#if USE_POLL
 
279
    memset(&fd, 0, sizeof(fd));
 
280
    fd.fd = c->fd;
 
281
    fd.events = POLLIN;
 
282
#else
270
283
    FD_ZERO(&rfds);
271
284
    FD_SET(c->fd, &rfds);
 
285
#endif
272
286
    ++c->in.reading;
273
287
 
 
288
#if USE_POLL
 
289
    if(count)
 
290
    {
 
291
        fd.events |= POLLOUT;
 
292
        ++c->out.writing;
 
293
    }
 
294
#else
274
295
    FD_ZERO(&wfds);
275
296
    if(count)
276
297
    {
277
298
        FD_SET(c->fd, &wfds);
278
299
        ++c->out.writing;
279
300
    }
 
301
#endif
280
302
 
281
303
    pthread_mutex_unlock(&c->iolock);
282
304
    do {
 
305
#if USE_POLL
 
306
    ret = poll(&fd, 1, -1);
 
307
#else
283
308
        ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
 
309
#endif
284
310
    } while (ret == -1 && errno == EINTR);
285
311
    if (ret < 0)
286
312
    {
291
317
 
292
318
    if(ret)
293
319
    {
 
320
#if USE_POLL
 
321
        if((fd.revents & POLLIN) == POLLIN)
 
322
#else
294
323
        if(FD_ISSET(c->fd, &rfds))
 
324
#endif
295
325
            ret = ret && _xcb_in_read(c);
296
326
 
 
327
#if USE_POLL
 
328
        if((fd.revents & POLLOUT) == POLLOUT)
 
329
#else
297
330
        if(FD_ISSET(c->fd, &wfds))
 
331
#endif
298
332
            ret = ret && write_vec(c, vector, count);
299
333
    }
300
334