Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

db_purge bugs in zlib support #3145

Closed
stream1972 opened this issue May 14, 2019 · 2 comments · Fixed by #3146
Closed

db_purge bugs in zlib support #3145

stream1972 opened this issue May 14, 2019 · 2 comments · Fixed by #3146

Comments

@stream1972
Copy link
Contributor

There are two bugs in db_purge zlib support code:

  1. Wrong archive streams flushed (copy-paste programming...)
  2. Z_FULL_FLUSH must not be used as it clears compression dictionary, this ruins compression. Use Z_SYNC_FLUSH instead.
    The diff below fixed these issues.
diff --git a/sched/db_purge.cpp b/sched/db_purge.cpp
--- a/sched/db_purge.cpp
+++ b/sched/db_purge.cpp
@@ -504,7 +508,7 @@ int archive_result_gz (DB_RESULT& result) {
         fail("ERROR: writing result archive failed\n");
     }
 
-    n = gzflush((gzFile)re_stream, Z_FULL_FLUSH);
+    n = gzflush((gzFile)re_stream, Z_SYNC_FLUSH);
     if (n != Z_OK) {
         fail("ERROR: writing result archive failed (flush)\n");
     }
@@ -538,7 +542,7 @@ int archive_wu_gz (DB_WORKUNIT& wu) {
         fail("ERROR: writing workunit archive failed\n");
     }
 
-    n = gzflush((gzFile)re_stream,Z_FULL_FLUSH);
+    n = gzflush((gzFile)wu_stream,Z_SYNC_FLUSH);
     if (n != Z_OK) {
         fail("ERROR: writing workunit archive failed (flush)\n");
     }
@@ -551,7 +555,7 @@ int archive_wu_gz (DB_WORKUNIT& wu) {
         fail("ERROR: writing workunit index failed\n");
     }
 
-    n = gzflush((gzFile)re_stream,Z_SYNC_FLUSH);
+    n = gzflush((gzFile)wu_index_stream,Z_SYNC_FLUSH);
     if (n != Z_OK) {
         fail("ERROR: writing workunit index failed (flush)\n");
     }
@AenBleidd
Copy link
Member

@stream1972, could you please create pull request with your fixes? If no - just let me know and I'll do this by myself

@stream1972
Copy link
Contributor Author

@AenBleidd Please be so kind and create pull request yourself. My own working tree is a mess from different patches and cherrypicks of different ages.

AenBleidd pushed a commit to AenBleidd/boinc that referenced this issue May 14, 2019
There are two bugs in db_purge zlib support code:
1. Wrong archive streams flushed (copy-paste programming...)
2. `Z_FULL_FLUSH` must not be used as it clears compression dictionary, this ruins compression. Use `Z_SYNC_FLUSH` instead.

This fixes BOINC#3145

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
@AenBleidd AenBleidd added this to the Server Release 1.0 milestone May 14, 2019
@AenBleidd AenBleidd added this to Server Aug 14, 2023
@AenBleidd AenBleidd moved this to Done in Server Aug 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants