-# Calculate the total amount of data we need to queue: rmem_max in the
-# kernel plus 1024 kB in jsonrpc-server sending userspace (see default
-# backlog_threshold in ovsdb_jsonrpc_session_create() in
-# jsonrpc-server.c).
-queue_size=`expr $rmem_max + 1024 \* 1024`
-echo rmem_max=$rmem_max queue_size=$queue_size
-
-# Each flow update message takes up at least 48 bytes of space in queues
-# and in practice more than that.
-n_msgs=`expr $queue_size / 48`
-echo n_msgs=$n_msgs
+
+# Calculate the number of iterations we need to queue. Each of the
+# iterations we execute, by itself, yields a monitor update of about
+# 25 kB, so fill up that much space plus a few for luck.
+n_iterations=`expr $rmem_max / 25000 + 5`
+echo rmem_max=$rmem_max n_iterations=$n_iterations
+
+# If there's too much queuing skip the test to avoid timing out.
+AT_SKIP_IF([test $rmem_max -gt 1048576])
+
+# Calculate the exact number of monitor updates expected for $n_iterations,
+# assuming no updates are combined. The "extra" update is for the initial
+# contents of the database.
+n_updates=`expr $n_iterations \* 3 + 1`