Browse Source

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

tags/v0.9.8
Michael Brown 15 years ago
parent
commit
04878ef745
5 changed files with 14 additions and 3 deletions
  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 View File

37
  * Add process to process list
37
  * Add process to process list
38
  *
38
  *
39
  * @v process		Process
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
 void process_add ( struct process *process ) {
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 View File

47
 process_init_stopped ( struct process *process,
47
 process_init_stopped ( struct process *process,
48
 		       void ( * step ) ( struct process *process ),
48
 		       void ( * step ) ( struct process *process ),
49
 		       struct refcnt *refcnt ) {
49
 		       struct refcnt *refcnt ) {
50
+	INIT_LIST_HEAD ( &process->list );
50
 	process->step = step;
51
 	process->step = step;
51
 	process->refcnt = refcnt;
52
 	process->refcnt = refcnt;
52
 }
53
 }

+ 1
- 0
src/net/infiniband.c View File

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

+ 1
- 0
src/net/netdevice.c View File

625
 
625
 
626
 /** Networking stack process */
626
 /** Networking stack process */
627
 struct process net_process __permanent_process = {
627
 struct process net_process __permanent_process = {
628
+	.list = LIST_HEAD_INIT ( net_process.list ),
628
 	.step = net_step,
629
 	.step = net_step,
629
 };
630
 };

+ 1
- 0
src/net/retry.c View File

187
 
187
 
188
 /** Retry timer process */
188
 /** Retry timer process */
189
 struct process retry_process __permanent_process = {
189
 struct process retry_process __permanent_process = {
190
+	.list = LIST_HEAD_INIT ( retry_process.list ),
190
 	.step = retry_step,
191
 	.step = retry_step,
191
 };
192
 };

Loading…
Cancel
Save