Hi Anatoli,

Thanks for the report.  I'm not sure that we even need the deflatePending() call, since we use deflateBound() to create an appropriately-sized buffer to hold the entire compressed response body.  Let me do some testing.


On 6/2/20 3:48 AM, Anatoli wrote:
Cyrus developers,

Is it possible to somehow rework the code in imap/httpd.c lines 158-169
in order to NOT use deflatePending as this func is not available on
OpenBSD? The zlib version there is 1.2.3 and deflatePending appeared in
1.2.5 so the code doesn't compile with --enable-http (undefined symbol:
deflatePending). The packaged version disables http for now.

Is it safe to reduce these lines:

  158         if (!zstrm->avail_out) {
  159             unsigned pending;
  160
  161             zr = deflatePending(zstrm, &pending, Z_NULL);
  162             if (zr != Z_OK) {
  163                 /* something went wrong */
  164                 syslog(LOG_ERR, "zlib deflate error: %d %s", zr,
zstrm->msg);
  165                 return -1;
  166             }
  167
  168             buf_ensure(&txn->zbuf, pending);
  169         }


to something like:

  158         if (!zstrm->avail_out) {
  159             buf_ensure(&txn->zbuf, 256 * 1024);
  160         }

If I understand it correctly, deflatePending in this case is only used
to get the needed buffer size and we could replace it with a hardcoded
buffer size (like in my example of 256K).


Thanks,
Anatoli

--
Kenneth Murchison
Senior Software Developer
Fastmail US LLC

Reply via email to