Mercurial > libavformat.hg
comparison tcp.c @ 2056:eeea52739ff3 libavformat
use ff_neterrno() and FF_NETERROR() for networking error handling
author | alex |
---|---|
date | Fri, 27 Apr 2007 00:35:54 +0000 |
parents | 612d19cb9550 |
children | 857fbfeb2fa0 |
comparison
equal
deleted
inserted
replaced
2055:3d553a42427a | 2056:eeea52739ff3 |
---|---|
66 | 66 |
67 redo: | 67 redo: |
68 ret = connect(fd, (struct sockaddr *)&dest_addr, | 68 ret = connect(fd, (struct sockaddr *)&dest_addr, |
69 sizeof(dest_addr)); | 69 sizeof(dest_addr)); |
70 if (ret < 0) { | 70 if (ret < 0) { |
71 if (errno == EINTR) | 71 if (ff_neterrno() == FF_NETERROR(EINTR)) |
72 goto redo; | 72 goto redo; |
73 if (errno != EINPROGRESS) | 73 if (ff_neterrno() != FF_NETERROR(EINPROGRESS)) |
74 goto fail; | 74 goto fail; |
75 | 75 |
76 /* wait until we are connected or until abort */ | 76 /* wait until we are connected or until abort */ |
77 for(;;) { | 77 for(;;) { |
78 if (url_interrupt_cb()) { | 78 if (url_interrupt_cb()) { |
124 tv.tv_usec = 100 * 1000; | 124 tv.tv_usec = 100 * 1000; |
125 ret = select(fd_max + 1, &rfds, NULL, NULL, &tv); | 125 ret = select(fd_max + 1, &rfds, NULL, NULL, &tv); |
126 if (ret > 0 && FD_ISSET(s->fd, &rfds)) { | 126 if (ret > 0 && FD_ISSET(s->fd, &rfds)) { |
127 len = recv(s->fd, buf, size, 0); | 127 len = recv(s->fd, buf, size, 0); |
128 if (len < 0) { | 128 if (len < 0) { |
129 if (errno != EINTR && errno != EAGAIN) | 129 if (ff_neterrno() != FF_NETERROR(EINTR) && |
130 ff_neterrno() != FF_NETERROR(EAGAIN)) | |
130 return AVERROR(errno); | 131 return AVERROR(errno); |
131 } else return len; | 132 } else return len; |
132 } else if (ret < 0) { | 133 } else if (ret < 0) { |
133 return -1; | 134 return -1; |
134 } | 135 } |
153 tv.tv_usec = 100 * 1000; | 154 tv.tv_usec = 100 * 1000; |
154 ret = select(fd_max + 1, NULL, &wfds, NULL, &tv); | 155 ret = select(fd_max + 1, NULL, &wfds, NULL, &tv); |
155 if (ret > 0 && FD_ISSET(s->fd, &wfds)) { | 156 if (ret > 0 && FD_ISSET(s->fd, &wfds)) { |
156 len = send(s->fd, buf, size, 0); | 157 len = send(s->fd, buf, size, 0); |
157 if (len < 0) { | 158 if (len < 0) { |
158 if (errno != EINTR && errno != EAGAIN) | 159 if (ff_neterrno() != FF_NETERROR(EINTR) && |
160 ff_neterrno() != FF_NETERROR(EAGAIN)) | |
159 return AVERROR(errno); | 161 return AVERROR(errno); |
160 continue; | 162 continue; |
161 } | 163 } |
162 size -= len; | 164 size -= len; |
163 buf += len; | 165 buf += len; |