diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-03-23 17:50:37 +0100 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-03-23 17:50:37 +0100 |
| commit | 03ad55130b4f0047eb64d3cc9947b98f0130623e (patch) | |
| tree | 1f9014a5a92335051541d34710e3556781d044a8 /src/client | |
| parent | 3939238f3fe46ed36919f29cbebe824341689960 (diff) | |
| download | BT-Programming-Assignment-03ad55130b4f0047eb64d3cc9947b98f0130623e.tar.gz BT-Programming-Assignment-03ad55130b4f0047eb64d3cc9947b98f0130623e.zip | |
fix terminology
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/client.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index cbaddeb..e7853a8 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -98,13 +98,13 @@ bool Client::request_processed(SharedMemory* shared_memory, int index) return true; } - for (int i = shared_memory->head - 1; i != shared_memory->tail; i = (i - 1) % QUEUE_SIZE) { + for (int i = shared_memory->head; i != shared_memory->tail; i = (i + 1) % QUEUE_SIZE) { if (i == index) { return false; } } - return shared_memory->tail != index; + return true; } int Client::send_request( @@ -121,12 +121,12 @@ int Client::send_request( pthread_cond_wait(&shared_memory->cond_var, &shared_memory->mutex); } - index = shared_memory->head; + index = shared_memory->tail; Request* request = &shared_memory->request[index]; request->type = type; strncpy(request->key, k.value_or("null").c_str(), MAX_KEY_SIZE); strncpy(request->value, v.value_or("null").c_str(), MAX_VALUE_SIZE); - shared_memory->head = (1 + shared_memory->head) % QUEUE_SIZE; + shared_memory->tail = (1 + shared_memory->tail) % QUEUE_SIZE; shared_memory->full = shared_memory->head == shared_memory->tail; pthread_cond_signal(&shared_memory->cond_var); |