s3:libsmb: move cli->vuid to cli->smb1.uid and hide it behind cli_state_[g|s]et_uid()
[kai/samba.git] / source3 / client / dnsbrowse.c
index c4819cebfa70a62a540af08b5bada69a343db6ff..03f87afe140031d1640f295246a9c873d55956bf 100644 (file)
 */
 
 #include "includes.h"
+#include "client/client_proto.h"
 
 #ifdef WITH_DNSSD_SUPPORT
 
 #include <dns_sd.h>
+#include "system/select.h"
 
 /* Holds service instances found during DNS browse */
 struct mdns_smbsrv_result
@@ -59,7 +61,6 @@ static void do_smb_resolve(struct mdns_smbsrv_result *browsesrv)
        int mdnsfd;
        int fdsetsz;
        int ret;
-       fd_set *fdset = NULL;
        struct timeval tv;
        DNSServiceErrorType err;
 
@@ -76,24 +77,14 @@ static void do_smb_resolve(struct mdns_smbsrv_result *browsesrv)
 
        mdnsfd = DNSServiceRefSockFD(mdns_conn_sdref);
        for (;;)  {
-               if (fdset != NULL) {
-                       TALLOC_FREE(fdset);
-               }
-
-               fdsetsz = howmany(mdnsfd + 1, NFDBITS) * sizeof(fd_mask);
-               fdset = TALLOC_ZERO(ctx, fdsetsz);
-               FD_SET(mdnsfd, fdset);
-
-               tv.tv_sec = 1;
-               tv.tv_usec = 0;
+               int revents;
 
-               /* Wait until response received from mDNS daemon */
-               ret = sys_select(mdnsfd + 1, fdset, NULL, NULL, &tv);
+               ret = poll_one_fd(mdnsfd, POLLIN|POLLHUP, 1000, &revents);
                if (ret <= 0 && errno != EINTR) {
                        break;
                }
 
-               if (FD_ISSET(mdnsfd, fdset)) {
+               if (revents & (POLLIN|POLLHUP|POLLERR)) {
                        /* Invoke callback function */
                        DNSServiceProcessResult(mdns_conn_sdref);
                        break;
@@ -133,7 +124,7 @@ do_smb_browse_reply(DNSServiceRef sdRef, DNSServiceFlags flags,
                return;
        }
 
-       bresult = TALLOC_ARRAY(talloc_tos(), struct mdns_smbsrv_result, 1);
+       bresult = talloc_array(talloc_tos(), struct mdns_smbsrv_result, 1);
        if (bresult == NULL) {
                return;
        }
@@ -154,7 +145,6 @@ int do_smb_browse(void)
        int mdnsfd;
        int fdsetsz;
        int ret;
-       fd_set *fdset = NULL;
        struct mdns_browse_state bstate;
        struct mdns_smbsrv_result *resptr;
        struct timeval tv;
@@ -176,24 +166,14 @@ int do_smb_browse(void)
 
        mdnsfd = DNSServiceRefSockFD(mdns_conn_sdref);
        for (;;)  {
-               if (fdset != NULL) {
-                       TALLOC_FREE(fdset);
-               }
-
-               fdsetsz = howmany(mdnsfd + 1, NFDBITS) * sizeof(fd_mask);
-               fdset = TALLOC_ZERO(ctx, fdsetsz);
-               FD_SET(mdnsfd, fdset);
-
-               tv.tv_sec = 1;
-               tv.tv_usec = 0;
+               int revents;
 
-               /* Wait until response received from mDNS daemon */
-               ret = sys_select(mdnsfd + 1, fdset, NULL, NULL, &tv);
+               ret = poll_one_fd(mdnsfd, POLLIN|POLLHUP, &revents, 1000);
                if (ret <= 0 && errno != EINTR) {
                        break;
                }
 
-               if (FD_ISSET(mdnsfd, fdset)) {
+               if (revents & (POLLIN|POLLHUP|POLLERR)) {
                        /* Invoke callback function */
                        if (DNSServiceProcessResult(mdns_conn_sdref)) {
                                break;