chiark / gitweb /
The server should now come to life straight away and start picking
authorRichard Kettlewell <rjk@greenend.org.uk>
Mon, 14 Jan 2008 23:11:12 +0000 (23:11 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Mon, 14 Jan 2008 23:11:12 +0000 (23:11 +0000)
random tracks within a reasonable time period once there are some
tracks to pick.

To cope with this, tests/queue.py now waits for something to appear in
the queue at all before checking its length.  This includes a fix to
the Python implementation of disorder().log().

python/disorder.py.in
server/disorderd.c
tests/queue.py

index 36157a0a8dbb39e065f10bca3ba91b5b7bd087ae..8fe7d21ec0d69dc53ccab45a0680f1162a414918 100644 (file)
@@ -768,7 +768,8 @@ class client:
     second the line from the event log.
     
     The callback should return True to continue or False to stop (don't
-    forget this, or your program will mysteriously misbehave).
+    forget this, or your program will mysteriously misbehave).  Once you
+    stop reading the log the connection is useless and should be deleted.
 
     It is suggested that you use the disorder.monitor class instead of
     calling this method directly, but this is not mandatory.
@@ -788,11 +789,6 @@ class client:
         l = l[1:]
       if not callback(self, l):
         break
-    # tell the server to stop sending, eat the remains of the body,
-    # eat the response
-    self._send("version")
-    self._body()
-    self._response()
 
   def pause(self):
     """Pause the current track."""
index 15e35727c46e82a34eba2590bce322f756f172cd..e03e4d777dc665f994d3a5129f910edb031bc05f 100644 (file)
@@ -290,17 +290,10 @@ int main(int argc, char **argv) {
   if(ev_signal(ev, SIGTERM, handle_sigterm, 0)) fatal(0, "ev_signal failed");
   /* ignore SIGPIPE */
   signal(SIGPIPE, SIG_IGN);
-  /* Start a rescan straight away if this is a new installation.  This rescan
-   * blocks; the point is that when it is finished we are in a good position to
-   * choose a random track. */
-  if(!trackdb_existing_database) {
-    trackdb_rescan(0/*ev*/, 0/*check*/);
-    /* No ev -> the rescan will block.  Since we called reconfigure() already
-     * any clients will also be forced to block. */
-  }
-  /* Start a second rescan, with length checking enabled, immediately after
-   * startup. */
-  rescan_after(1);
+  /* Start a rescan straight away */
+  trackdb_rescan(ev, 1/*check*/);
+  /* We'll rescan again after a day */
+  rescan_after(86400);
   /* periodically tidy up the database */
   dbgc_after(60);
   /* periodically check the volume */
index c78d6ed82c5ecd8f7297402cd58ed7807144d47d..4deb88d40de223eb3525ff1ee31ada1a5774746d 100755 (executable)
@@ -24,6 +24,11 @@ def test():
     """Check the queue is padded to the (default) configured length"""
     dtest.start_daemon()
     dtest.create_user()
+    print " waiting for queue to be populated..."
+    class wait_monitor(disorder.monitor):
+        def queue(self, q):
+            return False
+    wait_monitor().run()
     c = disorder.client()
     print " getting queue via python module"
     q = c.queue()