#include "http.h"
 #include "mcast.h"
 
-#define CHUNKSIZE 3000
-#define GTOD_INTERVAL 100
+#define CHUNKSIZE      3000
+#define GTOD_INTERVAL  100
+#define MAX_ERROR_SLEEP        60
 
 void record(int(*open_fn)(char *), char *url, char *outfile, int duration)
 {
                        sleep(error_sleep);
                        printf("Reconnecting... ");
                        if ((in = (*open_fn)(url)) < 0) {
-                               if (error_sleep < 60)
+                               if (error_sleep < MAX_ERROR_SLEEP)
                                        error_sleep *= 2;
 
+                               if (error_sleep > MAX_ERROR_SLEEP)
+                                       error_sleep = MAX_ERROR_SLEEP;
+
                                printf("failed\n");
                                continue;
                        } else {