Revert the "reverse" change to rpc_server/srv_spoolss_nt.c, simply
authorJeremy Allison <jra@samba.org>
Thu, 5 Sep 2002 12:55:56 +0000 (12:55 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 5 Sep 2002 12:55:56 +0000 (12:55 +0000)
add then entries to the end of the list in printing/notify.c using
DLIST_ADD_END.
Jeremy.
(This used to be commit 047d6a05fb60172a2607bb7d7d03dda5403c61fa)

source3/printing/notify.c
source3/rpc_server/srv_spoolss_nt.c

index 728ef47d8ab082580f9f89f24c4f63c3e2453c6e..003718ed72499c2221e4a607ad1654fe32c1a63e 100644 (file)
@@ -102,7 +102,7 @@ static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
 {
        char *buf = NULL;
        size_t buflen = 0, len;
-       struct notify_queue *pnqueue;
+       struct notify_queue *pnqueue, *tmp_ptr;
 
        /* Let's not waste any time with this */
 
@@ -155,7 +155,11 @@ again:
 
        DEBUG(5, ("send_spoolss_notify2_msg: appending message 0x%02x/0x%02x to notify_queue_head\n", msg->type, msg->field));
                  
-       DLIST_ADD(notify_queue_head, pnqueue);
+       /* Note we add to the end of the list to ensure
+        * the messages are sent in the order they were received. JRA.
+        */
+       DLIST_ADD_END(notify_queue_head, pnqueue, tmp_ptr);
+
        return;
 
   fail:
index aa63284322c30b0faa451a9ce6deb048a4c9fb8f..3a2bde2d05fdae92fb8db3b4c1c687dc30a4a6fa 100644 (file)
@@ -889,9 +889,9 @@ static void receive_notify2_message(void *buf, size_t len)
 
 static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len)
 {
-       size_t msg_count, *msg_len_array, i;
+       size_t msg_count, i;
        char *buf = (char *)msg;
-       char *msg_ptr, **msg_ptr_array;
+       char *msg_ptr;
 
        if (len < 4)
                goto bad_msg;
@@ -904,24 +904,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz
        if (msg_count == 0)
                goto bad_msg;
 
-       /* Process notifies in *reverse* order in which they are sent
-          in the message.  This is because a DLIST_ADD is used by the
-          message sender which results in the first (post!) message
-          being at the end of the list.  Notify messages must be
-          delivered in the order the events occur in otherwise the
-          port monitor gets confused. */
-
-       if (!(msg_len_array = (size_t *)malloc(sizeof(size_t) * msg_count))) {
-               DEBUG(0, ("receive_notify2_message_list: out of memory\n"));
-               return;
-       }
-
-       if (!(msg_ptr_array = (char **)malloc(sizeof(char *) * msg_count))) {
-               SAFE_FREE(msg_len_array);
-               DEBUG(0, ("receive_notify2_message_list: out of memory\n"));
-               return;
-       }
-
        for (i = 0; i < msg_count; i++) {
                size_t msg_len;
 
@@ -933,19 +915,10 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz
 
                if (msg_ptr + msg_len - buf > len)
                        goto bad_msg;
-
-               msg_len_array[i] = msg_len;
-               msg_ptr_array[i] = msg_ptr;
-
+               receive_notify2_message(msg_ptr, msg_len);
                msg_ptr += msg_len;
        }
 
-       for(i = msg_count; i > 0; i--)
-               receive_notify2_message(msg_ptr_array[i - 1], msg_len_array[i - 1]);
-
-       SAFE_FREE(msg_len_array);
-       SAFE_FREE(msg_ptr_array);
-
        DEBUG(10,("receive_notify2_message_list: processed %u messages\n",
                (unsigned int)msg_count ));
        return;