Revision ebba2b3e libavformat/tcp.c

View differences:

libavformat/tcp.c
131 131
    return ret;
132 132
}
133 133

  
134
static int tcp_wait_fd(int fd, int write)
135
{
136
    int ev = write ? POLLOUT : POLLIN;
137
    struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
138
    int ret;
139

  
140
    ret = poll(&p, 1, 100);
141
    return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
142
}
143

  
144 134
static int tcp_read(URLContext *h, uint8_t *buf, int size)
145 135
{
146 136
    TCPContext *s = h->priv_data;
147 137
    int ret;
148 138

  
149 139
    if (!(h->flags & URL_FLAG_NONBLOCK)) {
150
        ret = tcp_wait_fd(s->fd, 0);
140
        ret = ff_network_wait_fd(s->fd, 0);
151 141
        if (ret < 0)
152 142
            return ret;
153 143
    }
......
161 151
    int ret;
162 152

  
163 153
    if (!(h->flags & URL_FLAG_NONBLOCK)) {
164
        ret = tcp_wait_fd(s->fd, 1);
154
        ret = ff_network_wait_fd(s->fd, 1);
165 155
        if (ret < 0)
166 156
            return ret;
167 157
    }

Also available in: Unified diff