s3: Slightly simplify winbind_write_sock
authorVolker Lendecke <vl@samba.org>
Thu, 10 Feb 2011 13:59:39 +0000 (14:59 +0100)
committerVolker Lendecke <vlendec@samba.org>
Thu, 10 Feb 2011 16:00:46 +0000 (17:00 +0100)
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Thu Feb 10 17:00:46 CET 2011 on sn-devel-104

nsswitch/wb_common.c

index 9a3788a0722a9fa4e74c0b9be5af54b514cce461..ccc5142d9c06e16d4e69626224af39d0a03532fb 100644 (file)
@@ -403,31 +403,29 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
 
                /* Write should be OK if fd not available for reading */
 
-               if (!FD_ISSET(winbindd_fd, &r_fds)) {
+               if (FD_ISSET(winbindd_fd, &r_fds)) {
 
-                       /* Do the write */
+                       /* Pipe has closed on remote end */
 
-                       result = write(winbindd_fd,
-                                      (char *)buffer + nwritten,
-                                      count - nwritten);
+                       winbind_close_sock();
+                       goto restart;
+               }
 
-                       if ((result == -1) || (result == 0)) {
+               /* Do the write */
 
-                               /* Write failed */
+               result = write(winbindd_fd,
+                              (char *)buffer + nwritten,
+                              count - nwritten);
 
-                               winbind_close_sock();
-                               return -1;
-                       }
-
-                       nwritten += result;
+               if ((result == -1) || (result == 0)) {
 
-               } else {
-
-                       /* Pipe has closed on remote end */
+                       /* Write failed */
 
                        winbind_close_sock();
-                       goto restart;
+                       return -1;
                }
+
+               nwritten += result;
        }
 
        return nwritten;