aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-06-13 17:27:08 +0530
committersinanmohd <sinan@sinanmohd.com>2024-06-13 17:27:08 +0530
commit6627adcbc2d2ade8db1fd2ed26e03d37b53fde62 (patch)
tree061d2a0151363215c2b65d625f093bd86aa964a6 /src
parent72d7ace64d2b511fe810e3d2564b3372afbe365f (diff)
util/json_streaming_read: properly handle EOF
Diffstat (limited to 'src')
-rw-r--r--src/jobs.c2
-rw-r--r--src/queue.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/jobs.c b/src/jobs.c
index b5fd31c..0205c71 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -141,7 +141,7 @@ int job_read(FILE *stream, struct job **job)
char *drv_path = NULL;
ret = json_streaming_read(stream, &root);
- if (ret < 0)
+ if (ret < 0 || ret == -EOF)
return ret;
temp = cJSON_GetObjectItemCaseSensitive(root, "name");
diff --git a/src/queue.c b/src/queue.c
index 5c196aa..6bf9092 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -16,9 +16,10 @@ void *queue_thread_entry(void *queue_thread)
while (true) {
ret = job_read(qt->stream, &job);
- if (ret < 0) {
- if (ret == -EOF)
- ret = 0;
+ if (ret == -EOF) {
+ ret = 0;
+ break;
+ } else if (ret < 0) {
break;
}