chiark
/
gitweb
/
~mdw
/
disorder
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
026a72d
)
Use new random_id() for queue IDs
author
Richard Kettlewell
<rjk@greenend.org.uk>
Sun, 25 May 2008 13:35:45 +0000
(14:35 +0100)
committer
Richard Kettlewell
<rjk@greenend.org.uk>
Sun, 25 May 2008 13:35:45 +0000
(14:35 +0100)
server/server-queue.c
patch
|
blob
|
blame
|
history
diff --git
a/server/server-queue.c
b/server/server-queue.c
index 71262886ec1b1d123605961616eb523ac4cb2a57..b71d67773571298491b30f1c40a2210d02d6eaa4 100644
(file)
--- a/
server/server-queue.c
+++ b/
server/server-queue.c
@@
-1,6
+1,6
@@
/*
* This file is part of DisOrder.
/*
* This file is part of DisOrder.
- * Copyright (C) 2004
, 2005, 2006, 2007
Richard Kettlewell
+ * Copyright (C) 2004
-2008
Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-35,7
+35,7
@@
#include "server-queue.h"
#include "eventlog.h"
#include "plugin.h"
#include "server-queue.h"
#include "eventlog.h"
#include "plugin.h"
-#include "
basen
.h"
+#include "
random
.h"
#include "configuration.h"
#include "inputline.h"
#include "disorder.h"
#include "configuration.h"
#include "inputline.h"
#include "disorder.h"
@@
-155,16
+155,22
@@
void recent_write(void) {
queue_do_write(&phead, config_get_file("recent"));
}
queue_do_write(&phead, config_get_file("recent"));
}
+static int id_in_use(const char *id) {
+ struct queue_entry *q;
+
+ for(q = qhead.next; q != &qhead; q = q->next)
+ if(!strcmp(id, q->id))
+ return 1;
+ return 0;
+}
+
static void queue_id(struct queue_entry *q) {
static void queue_id(struct queue_entry *q) {
- static unsigned long serial;
- unsigned long a[3];
- char buffer[128];
-
- a[0] = serial++ & 0xFFFFFFFFUL;
- a[1] = time(0) & 0xFFFFFFFFUL;
- a[2] = getpid() & 0xFFFFFFFFUL;
- basen(a, 3, buffer, sizeof buffer, 62);
- q->id = xstrdup(buffer);
+ const char *id;
+
+ id = random_id();
+ while(id_in_use(id))
+ id = random_id();
+ q->id = id;
}
struct queue_entry *queue_add(const char *track, const char *submitter,
}
struct queue_entry *queue_add(const char *track, const char *submitter,