Pārlūkot izejas kodu

[process] Make it safe to call process_add() multiple times

tags/v0.9.8
Michael Brown 15 gadus atpakaļ
vecāks
revīzija
04878ef745
5 mainītis faili ar 14 papildinājumiem un 3 dzēšanām
  1. 10
    3
      src/core/process.c
  2. 1
    0
      src/include/gpxe/process.h
  3. 1
    0
      src/net/infiniband.c
  4. 1
    0
      src/net/netdevice.c
  5. 1
    0
      src/net/retry.c

+ 10
- 3
src/core/process.c Parādīt failu

@@ -37,11 +37,18 @@ static LIST_HEAD ( run_queue );
37 37
  * Add process to process list
38 38
  *
39 39
  * @v process		Process
40
+ *
41
+ * It is safe to call process_add() multiple times; further calls will
42
+ * have no effect.
40 43
  */
41 44
 void process_add ( struct process *process ) {
42
-	DBGC ( process, "PROCESS %p starting\n", process );
43
-	ref_get ( process->refcnt );
44
-	list_add_tail ( &process->list, &run_queue );
45
+	if ( list_empty ( &process->list ) ) {
46
+		DBGC ( process, "PROCESS %p starting\n", process );
47
+		ref_get ( process->refcnt );
48
+		list_add_tail ( &process->list, &run_queue );
49
+	} else {
50
+		DBGC ( process, "PROCESS %p already started\n", process );
51
+	}
45 52
 }
46 53
 
47 54
 /**

+ 1
- 0
src/include/gpxe/process.h Parādīt failu

@@ -47,6 +47,7 @@ static inline __attribute__ (( always_inline )) void
47 47
 process_init_stopped ( struct process *process,
48 48
 		       void ( * step ) ( struct process *process ),
49 49
 		       struct refcnt *refcnt ) {
50
+	INIT_LIST_HEAD ( &process->list );
50 51
 	process->step = step;
51 52
 	process->refcnt = refcnt;
52 53
 }

+ 1
- 0
src/net/infiniband.c Parādīt failu

@@ -802,6 +802,7 @@ static void ib_step ( struct process *process __unused ) {
802 802
 
803 803
 /** Infiniband event queue process */
804 804
 struct process ib_process __permanent_process = {
805
+	.list = LIST_HEAD_INIT ( ib_process.list ),
805 806
 	.step = ib_step,
806 807
 };
807 808
 

+ 1
- 0
src/net/netdevice.c Parādīt failu

@@ -625,5 +625,6 @@ static void net_step ( struct process *process __unused ) {
625 625
 
626 626
 /** Networking stack process */
627 627
 struct process net_process __permanent_process = {
628
+	.list = LIST_HEAD_INIT ( net_process.list ),
628 629
 	.step = net_step,
629 630
 };

+ 1
- 0
src/net/retry.c Parādīt failu

@@ -187,5 +187,6 @@ static void retry_step ( struct process *process __unused ) {
187 187
 
188 188
 /** Retry timer process */
189 189
 struct process retry_process __permanent_process = {
190
+	.list = LIST_HEAD_INIT ( retry_process.list ),
190 191
 	.step = retry_step,
191 192
 };

Notiek ielāde…
Atcelt
Saglabāt