summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
authorDavid Troy <dave@popvox.com>2006-04-03 16:23:01 +0000
committerDavid Troy <dave@popvox.com>2006-04-03 16:23:01 +0000
commitbbf337d7f093d32703477f2722591ac08f8230bb (patch)
treef686336d5fdc65df4008a2fa57f5b861c3f5c780 /src/common.c
parentdc56649b0e188704512719be80ecb6f544cef0e7 (diff)
downloadastmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.tar.gz
astmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.tar.xz
astmanproxy-bbf337d7f093d32703477f2722591ac08f8230bb.zip
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@71 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/common.c b/src/common.c
index 39b5c93..98f33e0 100644
--- a/src/common.c
+++ b/src/common.c
@@ -43,22 +43,29 @@ int get_input(struct mansession *s, char *output)
fds[0].fd = get_real_fd(s->fd);
fds[0].events = POLLIN;
- res = poll(fds, 1, -1);
- if (debug > 3)
- debugmsg("returned from poll op");
-
- if (res < 0 && debug) {
- debugmsg("Select returned error");
- } else if (res > 0) {
- debugmsg("attempting socket read in get_input...");
-
- pthread_mutex_lock(&s->lock);
- /* read from socket; SSL or otherwise */
- res = m_recv(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen, 0);
- pthread_mutex_unlock(&s->lock);
- if (res < 1)
- return -1;
- }
+ do {
+ res = poll(fds, 1, -1);
+ if (res < 0) {
+ if (errno == EINTR) {
+ if (s->dead)
+ return -1;
+ continue;
+ }
+ if (debug)
+ debugmsg("Select returned error");
+ return -1;
+ } else if (res > 0) {
+ debugmsg("attempting socket read in get_input...");
+ pthread_mutex_lock(&s->lock);
+ /* read from socket; SSL or otherwise */
+ res = m_recv(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen, 0);
+ pthread_mutex_unlock(&s->lock);
+ if (res < 1)
+ return -1;
+ break;
+
+ }
+ } while(1);
/* We have some input, but it's not ready for processing */
s->inlen += res;