diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2010-09-02 05:02:54 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2010-09-02 05:02:54 +0000 |
commit | 5eae9f44f74f9869e46e416a2d5d092834043483 (patch) | |
tree | afc6eb9b08ef4ba9f7e0ad1bb4a59b13d5269d90 /res/res_jabber.c | |
parent | c28c620936e31ec5a63147ae20d82d621541ae90 (diff) |
Merged revisions 284597 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r284597 | tilghman | 2010-09-02 00:00:34 -0500 (Thu, 02 Sep 2010) | 29 lines
Merged revisions 284593,284595 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r284593 | tilghman | 2010-09-01 17:59:50 -0500 (Wed, 01 Sep 2010) | 18 lines
Merged revisions 284478 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r284478 | tilghman | 2010-09-01 13:49:11 -0500 (Wed, 01 Sep 2010) | 11 lines
Ensure that all areas that previously used select(2) now use poll(2), with implementations that need poll(2) implemented with select(2) safe against 1024-bit overflows.
This is a followup to the fix for the pthread timer in 1.6.2 and beyond, fixing
a potential crash bug in all supported releases.
(closes issue #17678)
Reported by: russell
Branch: https://origsvn.digium.com/svn/asterisk/team/tilghman/ast_select
Review: https://reviewboard.asterisk.org/r/824/
........
................
r284595 | tilghman | 2010-09-01 22:57:43 -0500 (Wed, 01 Sep 2010) | 2 lines
Failed to rerun bootstrap.sh after last commit
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@284598 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_jabber.c')
-rw-r--r-- | res/res_jabber.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c index 5238441f1..13c7bf2cd 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -1283,38 +1283,27 @@ static int aji_tls_handshake(struct aji_client *client) */ static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, int timeout) { - int sock; - fd_set fds; - struct timeval tv, *tvptr = NULL; + struct pollfd pfd = { .events = POLLIN }; int len, res; #ifdef HAVE_OPENSSL if (aji_is_secure(client)) { - sock = SSL_get_fd(client->ssl_session); - if (sock < 0) { + pfd.fd = SSL_get_fd(client->ssl_session); + if (pfd.fd < 0) { return -1; } } else #endif /* HAVE_OPENSSL */ - sock = iks_fd(client->p); - - memset(&tv, 0, sizeof(struct timeval)); - FD_ZERO(&fds); - FD_SET(sock, &fds); - tv.tv_sec = timeout; - - /* NULL value for tvptr makes ast_select wait indefinitely */ - tvptr = (timeout != -1) ? &tv : NULL; + pfd.fd = iks_fd(client->p); - /* ast_select emulates linux behaviour in terms of timeout handling */ - res = ast_select(sock + 1, &fds, NULL, NULL, tvptr); + res = ast_poll(&pfd, 1, timeout > 0 ? timeout * 1000 : -1); if (res > 0) { #ifdef HAVE_OPENSSL if (aji_is_secure(client)) { len = SSL_read(client->ssl_session, buffer, buf_len); } else #endif /* HAVE_OPENSSL */ - len = recv(sock, buffer, buf_len, 0); + len = recv(pfd.fd, buffer, buf_len, 0); if (len > 0) { return len; |