redo:
ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
if (ret < 0) {
+ int timeout=50;
struct pollfd p = {fd, POLLOUT, 0};
- if (ff_neterrno() == FF_NETERROR(EINTR)) {
- if (url_interrupt_cb())
+ if (ff_neterrno() == AVERROR(EINTR)) {
+ if (url_interrupt_cb()) {
+ ret = AVERROR_EXIT;
goto fail1;
+ }
goto redo;
}
- if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
- ff_neterrno() != FF_NETERROR(EAGAIN))
+ if (ff_neterrno() != AVERROR(EINPROGRESS) &&
+ ff_neterrno() != AVERROR(EAGAIN))
goto fail;
/* wait until we are connected or until abort */
for(;;) {
if (url_interrupt_cb()) {
- ret = AVERROR(EINTR);
+ ret = AVERROR_EXIT;
goto fail1;
}
ret = poll(&p, 1, 100);
if (ret > 0)
break;
+ if(!--timeout){
+ av_log(NULL, AV_LOG_ERROR,
+ "TCP open %s:%d timeout\n",
+ hostname, port);
+ goto fail;
+ }
}
/* test error */
int ret;
ret = poll(&p, 1, 100);
- return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : FF_NETERROR(EAGAIN);
+ return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
}
static int tcp_read(URLContext *h, uint8_t *buf, int size)