svn commit: samba r20485 - in branches: SAMBA_3_0/source/libaddns
SAMBA_3_0_24/source/libaddns
jerry at samba.org
jerry at samba.org
Tue Jan 2 21:20:40 GMT 2007
Author: jerry
Date: 2007-01-02 21:20:40 +0000 (Tue, 02 Jan 2007)
New Revision: 20485
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20485
Log:
Add select with a 10 second timeout when reading DSN update responses.
Modified:
branches/SAMBA_3_0/source/libaddns/dnssock.c
branches/SAMBA_3_0_24/source/libaddns/dnssock.c
Changeset:
Modified: branches/SAMBA_3_0/source/libaddns/dnssock.c
===================================================================
--- branches/SAMBA_3_0/source/libaddns/dnssock.c 2007-01-02 19:29:32 UTC (rev 20484)
+++ branches/SAMBA_3_0/source/libaddns/dnssock.c 2007-01-02 21:20:40 UTC (rev 20485)
@@ -213,15 +213,29 @@
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 );
- ssize_t ret = read(fd, data + total, len - total);
+ /* 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;
+ }
+ ret = read(fd, data + total, len - total);
if (ret <= 0) {
- /*
- * EOF or error
- */
+ /* EOF or error */
return ERROR_DNS_SOCKET_ERROR;
}
Modified: branches/SAMBA_3_0_24/source/libaddns/dnssock.c
===================================================================
--- branches/SAMBA_3_0_24/source/libaddns/dnssock.c 2007-01-02 19:29:32 UTC (rev 20484)
+++ branches/SAMBA_3_0_24/source/libaddns/dnssock.c 2007-01-02 21:20:40 UTC (rev 20485)
@@ -213,15 +213,29 @@
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 );
- ssize_t ret = read(fd, data + total, len - total);
+ /* 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;
+ }
+ ret = read(fd, data + total, len - total);
if (ret <= 0) {
- /*
- * EOF or error
- */
+ /* EOF or error */
return ERROR_DNS_SOCKET_ERROR;
}
More information about the samba-cvs
mailing list