Fixed Thomas's Bug.
In short: - When a large amount of input was recieved, the server would hang. - The server would hang on queue->lock for the input queue, in pushQueue(). - Upon debugging, it was revealed that queue->lock was actually false at this time. - GCC had optimized out the actual loop, leaving it to get stuck even though the variable had changed. - Adding the volatile keyword to the lock fixed this issue.
This commit is contained in:
parent
c2c77d6343
commit
a38cbb70a8
|
@ -157,6 +157,9 @@ void popQueue(queue * queue)
|
|||
// Adds data to the back of a queue:
|
||||
void pushQueue(queue * queue, void * data, queueDataType type)
|
||||
{
|
||||
// Check if the queue is locked:
|
||||
while (queue->lock);
|
||||
|
||||
// Create a new node:
|
||||
queueNode * newNode = malloc(sizeof(queueNode));
|
||||
newNode->type = type;
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct queueNode
|
|||
|
||||
typedef struct queue
|
||||
{
|
||||
bool lock;
|
||||
volatile bool lock;
|
||||
size_t itemCount;
|
||||
queueNode * front;
|
||||
queueNode * back;
|
||||
|
|
Loading…
Reference in New Issue