Author: vlendec
Date: 2005-09-30 11:56:39 +0000 (Fri, 30 Sep 2005)
New Revision: 10650

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10650

Log:
Send non-local messages via the dispatcher, allow message_select_dispatch wait
for a timeout

Volker

Modified:
   branches/tmp/vl-cluster/source/lib/messages.c
   branches/tmp/vl-cluster/source/nmbd/nmbd.c
   branches/tmp/vl-cluster/source/torture/msgtest.c
   branches/tmp/vl-cluster/source/utils/smbcontrol.c


Changeset:
Modified: branches/tmp/vl-cluster/source/lib/messages.c
===================================================================
--- branches/tmp/vl-cluster/source/lib/messages.c       2005-09-30 11:18:29 UTC 
(rev 10649)
+++ branches/tmp/vl-cluster/source/lib/messages.c       2005-09-30 11:56:39 UTC 
(rev 10650)
@@ -315,6 +315,10 @@
                memcpy(packet.data + sizeof(struct message_rec), buf, len);
        }
 
+       if (!procid_is_local(&hdr->dest)) {
+               goto via_stream;
+       }
+
        ZERO_STRUCT(sunaddr);
        sunaddr.sun_family = AF_UNIX;
        strncpy(sunaddr.sun_path, message_path(&pid),
@@ -350,6 +354,7 @@
                           "dispatcher in blocking mode\n"));
        }
 
+ via_stream:
        if ((stream_fd < 0) && !init_stream_socket()) {
                DEBUG(5, ("No stream socket\n"));
                goto done;
@@ -618,15 +623,14 @@
        return result;
 }
 
-void message_select_dispatch(void)
+void message_select_dispatch(struct timeval *tv)
 {
        fd_set rfds;
        int maxfd = 0;
-       struct timeval tv = timeval_zero();
 
        FD_ZERO(&rfds);
        message_select_setup(&maxfd, &rfds);
-       if (sys_select(maxfd+1, &rfds, NULL, NULL, &tv) > 0) {
+       if (sys_select(maxfd+1, &rfds, NULL, NULL, tv) > 0) {
                message_dispatch(&rfds);
        }
 }

Modified: branches/tmp/vl-cluster/source/nmbd/nmbd.c
===================================================================
--- branches/tmp/vl-cluster/source/nmbd/nmbd.c  2005-09-30 11:18:29 UTC (rev 
10649)
+++ branches/tmp/vl-cluster/source/nmbd/nmbd.c  2005-09-30 11:56:39 UTC (rev 
10650)
@@ -392,7 +392,10 @@
 
                /* Check for internal messages */
 
-               message_select_dispatch();
+               {
+                       struct timeval null = timeval_zero();
+                       message_select_dispatch(&null);
+               }
 
                /*
                 * Check all broadcast subnets to see if

Modified: branches/tmp/vl-cluster/source/torture/msgtest.c
===================================================================
--- branches/tmp/vl-cluster/source/torture/msgtest.c    2005-09-30 11:18:29 UTC 
(rev 10649)
+++ branches/tmp/vl-cluster/source/torture/msgtest.c    2005-09-30 11:56:39 UTC 
(rev 10650)
@@ -35,7 +35,7 @@
 
  int main(int argc, char *argv[])
 {
-       pid_t pid;
+       struct process_id pid;
        int i, n;
        char *buf;
 
@@ -50,9 +50,9 @@
        }
 
        if (strcmp(argv[1], "self") == 0) {
-               pid = getpid();
+               pid = procid_self();
        } else {
-               pid = atoi(argv[1]);
+               pid = interpret_pid(argv[1]);
        }
        n = atoi(argv[2]);
 
@@ -70,9 +70,11 @@
        for (i=0;i<n;i++) {
                fd_set rfds;
                int maxfd;
+               size_t size = 1024*512;
                FD_ZERO(&rfds);
-               message_send_pid(pid_to_procid(pid), MSG_PING, NULL, 0,
-                                True);
+               buf=SMB_MALLOC(size);
+               memset(buf, 0, size);
+               message_send_pid(pid, MSG_PING, buf, size, True);
                message_select_setup(&maxfd, &rfds);
                if (select(maxfd+1, &rfds, NULL, NULL, NULL) <= 0)
                        break;
@@ -80,13 +82,8 @@
        }
 
        while (pong_count < n) {
-               fd_set rfds;
-               int maxfd;
-               FD_ZERO(&rfds);
-               message_select_setup(&maxfd, &rfds);
-               if (select(maxfd+1, &rfds, NULL, NULL, NULL) <= 0)
-                       break;
-               message_dispatch(&rfds);
+               struct timeval tv = timeval_set(5, 0);
+               message_select_dispatch(&tv);
        }               
        DEBUG(0, ("expected %d, got back %d\n", n, pong_count));
 

Modified: branches/tmp/vl-cluster/source/utils/smbcontrol.c
===================================================================
--- branches/tmp/vl-cluster/source/utils/smbcontrol.c   2005-09-30 11:18:29 UTC 
(rev 10649)
+++ branches/tmp/vl-cluster/source/utils/smbcontrol.c   2005-09-30 11:56:39 UTC 
(rev 10650)
@@ -76,10 +76,11 @@
            busy-wait here as there is no nicer way to do it. */
 
        do {
-               message_select_dispatch();
-               if (num_replies > 0 && !multiple_replies)
-                       break;
-               sleep(1);
+               struct timeval tmo;
+               tmo = timeval_set(timeout - (time(NULL) - start_time), 0);
+               message_select_dispatch(&tmo);
+                if (num_replies > 0 && !multiple_replies)
+                        break;
        } while (timeout - (time(NULL) - start_time) > 0);
 }
 

Reply via email to