~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/ivykis/lib/iv_method_port.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2013-05-26 09:06:21 UTC
  • mfrom: (1.3.11)
  • Revision ID: package-import@ubuntu.com-20130526090621-8z2s0oi21eoljb9x
Tags: 3.3.9-1
* New upstream release.
* Include missed ivykis header (closes: #708793).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <stdio.h>
22
22
#include <stdlib.h>
 
23
#include <fcntl.h>
23
24
#include <port.h>
24
25
#include <string.h>
25
26
#include "iv_private.h"
29
30
static int iv_port_init(struct iv_state *st)
30
31
{
31
32
        int fd;
 
33
        int flags;
32
34
 
33
35
        fd = port_create();
34
36
        if (fd < 0)
35
37
                return -1;
36
38
 
 
39
        flags = fcntl(fd, F_GETFD);
 
40
        if (!(flags & FD_CLOEXEC)) {
 
41
                flags |= FD_CLOEXEC;
 
42
                fcntl(fd, F_SETFD, flags);
 
43
        }
 
44
 
37
45
        st->port.port_fd = fd;
38
46
 
39
47
        INIT_IV_LIST_HEAD(&st->port.notify);
104
112
 
105
113
poll_more:
106
114
        nget = 1;
 
115
 
 
116
        /*
 
117
         * If we get EINTR from port_getn(), no events are returned
 
118
         * and nget will not have been updated, but if we get ETIME,
 
119
         * events may be returned, and nget will be set to the number
 
120
         * of events in the array, and we need to process those
 
121
         * events as usual.
 
122
         */
107
123
        ret = port_getn(st->port.port_fd, pe, PORTEV_NUM, &nget, to);
108
 
        if (ret < 0) {
109
 
                if (errno == EINTR || errno == ETIME)
 
124
        if (ret < 0 && errno != ETIME) {
 
125
                if (errno == EINTR)
110
126
                        return;
111
127
 
112
128
                iv_fatal("iv_port_poll: got error %d[%s]", errno,