diff options
author | Gerald Carter <jerry@samba.org> | 2007-01-02 21:20:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:16:52 -0500 |
commit | 19f85cd9b96f291600012354ab668dbb0043c814 (patch) | |
tree | b9c17f42ec743ad5b7594b07c9e09b5af8f47a19 /source3/libaddns | |
parent | b3ddd92ba2dfbf732b3e6e22812bca780713ed8f (diff) | |
download | samba-19f85cd9b96f291600012354ab668dbb0043c814.tar.gz samba-19f85cd9b96f291600012354ab668dbb0043c814.tar.bz2 samba-19f85cd9b96f291600012354ab668dbb0043c814.zip |
r20485: Add select with a 10 second timeout when reading DSN update responses.
(This used to be commit cb6c6a49e257d60318101c897e8d2b86de08a846)
Diffstat (limited to 'source3/libaddns')
-rw-r--r-- | source3/libaddns/dnssock.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source3/libaddns/dnssock.c b/source3/libaddns/dnssock.c index 2f48df1bbd..5dbedc4fd5 100644 --- a/source3/libaddns/dnssock.c +++ b/source3/libaddns/dnssock.c @@ -213,15 +213,29 @@ DNS_ERROR dns_send(struct dns_connection *conn, const struct dns_buffer *buf) static DNS_ERROR read_all(int fd, uint8 *data, size_t len) { size_t total = 0; + fd_set rfds; + struct timeval tv; while (total < len) { + ssize_t ret; + int fd_ready; + + FD_ZERO( &rfds ); + FD_SET( fd, &rfds ); + + /* 10 second timeout */ + tv.tv_sec = 10; + tv.tv_usec = 0; + + fd_ready = select( fd+1, &rfds, NULL, NULL, &tv ); + if ( fd_ready == 0 ) { + /* read timeout */ + return ERROR_DNS_SOCKET_ERROR; + } - ssize_t ret = read(fd, data + total, len - total); - + ret = read(fd, data + total, len - total); if (ret <= 0) { - /* - * EOF or error - */ + /* EOF or error */ return ERROR_DNS_SOCKET_ERROR; } |