Changeset 23530 for trunk/Ohana/src/opihi/pantasks/InputQueue.c
- Timestamp:
- Mar 25, 2009, 11:56:09 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pantasks/InputQueue.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/InputQueue.c
r16449 r23530 1 1 # include "pantasks.h" 2 // we use fprintf for DEBUG statements to avoid deadlocking issues 2 3 3 4 static int Ninputs = 0; … … 23 24 void AddNewInput (char *input) { 24 25 26 // XXX define the InputMutex 25 27 SerialThreadLock (); 26 if (DEBUG) gprint (GP_LOG, "adding a new input (%s)\n", input); 28 29 if (DEBUG) fprintf (stderr, "adding a new input (%s)\n", input); 27 30 inputs[Ninputs] = input; 28 31 Ninputs ++; … … 31 34 REALLOCATE (inputs, char *, NINPUTS); 32 35 } 33 if (DEBUG) gprint (GP_LOG, "done new input (%s)\n", input);36 if (DEBUG) fprintf (stderr, "done new input (%s)\n", input); 34 37 SerialThreadUnlock (); 35 38 } … … 40 43 int i, j; 41 44 42 if (DEBUG) gprint (GP_LOG, "deleting an input (%s)\n", input); 45 if (DEBUG) fprintf (stderr, "deleting an input (%s)\n", input); 46 47 // XXX lock here 43 48 for (i = 0; i < Ninputs; i++) { 44 49 if (inputs[i] == input) { … … 52 57 REALLOCATE (inputs, char *, NINPUTS); 53 58 } 54 if (DEBUG) gprint (GP_LOG, "deleted an input\n"); 59 // XXX unlock here 60 if (DEBUG) fprintf (stderr, "deleted an input\n"); 55 61 return TRUE; 56 62 } 57 63 } 58 64 // did not find the input 65 // XXX unlock here 59 66 return FALSE; 60 67 } … … 66 73 char *input, *line, *outline, tmp; 67 74 68 if (Ninputs < 1) return; 75 // XXX lock here 76 if (Ninputs < 1) { 77 // XXX unlock here 78 return; 79 } 69 80 70 81 input = inputs[0]; 71 if (DEBUG) gprint (GP_LOG, "got an input (%s)\n", input);82 if (DEBUG) fprintf (stderr, "got an input (%s)\n", input); 72 83 73 84 Nbytes = snprintf (&tmp, 0, "input %s", input); 74 85 ALLOCATE (line, char, Nbytes + 1); 75 86 snprintf (line, Nbytes + 1, "input %s", input); 87 // XXX unlock here 76 88 77 89 status = command (line, &outline, TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
