Mercurial > hg
view contrib/fuzz/bdiff.cc @ 37291:b0041036214e
wireproto: define frame to represent progress updates
Today, a long-running operation on a server may run without any sign
of progress on the client. This can lead to the conclusion that the
server has hung or the connection has dropped. In fact, connections
can and do time out due to inactivity. And a long-running server
operation can result in the connection dropping prematurely because
no data is being sent!
While we're inventing the new wire protocol, let's provide a mechanism
for communicating progress on potentially expensive server-side events.
We introduce a new frame type that conveys "progress" updates. This
frame type essentially holds the data required to formulate a
``ui.progress()`` call.
We only define the frame right now. Implementing it will be a bit of
work since there is no analog to progress frames in the existing
wire protocol. We'll need to teach the ui object to write to the
wire protocol, etc.
The use of a CBOR map may seem wasteful, as this will encode key
names in every frame. This *is* wasteful. However, maps are
extensible. And the intent is to always use compression via
streams. Compression will make the overhead negligible since repeated
strings will be mostly eliminated over the wire.
Differential Revision: https://phab.mercurial-scm.org/D2902
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 26 Mar 2018 10:50:36 -0700 |
parents | 2b9e2415f5b5 |
children | fa0ddd5e8fff |
line wrap: on
line source
/* * bdiff.cc - fuzzer harness for bdiff.c * * Copyright 2018, Google Inc. * * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ #include <stdlib.h> extern "C" { #include "bdiff.h" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (!Size) { return 0; } // figure out a random point in [0, Size] to split our input. size_t split = Data[0] / 255.0 * Size; // left input to diff is data[1:split] const uint8_t *left = Data + 1; // which has len split-1 size_t left_size = split - 1; // right starts at the next byte after left ends const uint8_t *right = left + left_size; size_t right_size = Size - split; struct bdiff_line *a, *b; int an = bdiff_splitlines((const char *)left, split - 1, &a); int bn = bdiff_splitlines((const char *)right, right_size, &b); struct bdiff_hunk l; bdiff_diff(a, an, b, bn, &l); free(a); free(b); bdiff_freehunks(l.next); return 0; // Non-zero return values are reserved for future use. } #ifdef HG_FUZZER_INCLUDE_MAIN int main(int argc, char **argv) { const char data[] = "asdf"; return LLVMFuzzerTestOneInput((const uint8_t *)data, 4); } #endif } // extern "C"