Re: [Kolab-devel] my current patchset
Aaron Seigo <[email protected]> Sat, 02 Dec 2017 23:01:02 +0100
| Newsgroups | gmane.comp.kde.devel.kolab |
|---|---|
| Message-ID | <[email protected]> |
Hi, Responding to the guam patch part: there is a patch (attached) for eimap that fixed a client stall issue that seems to have been applied to the Enterprise repository packages, but not to the main repo[1]. this should also be applied to your build and tested as well. as for the guam patch, i'd be happy to review it (test, verify, clean up, etc.) if i could be given a way to reproduce. cheers. [1] I no longer have push access to those repositories, as on leaving the company Kolab Systems terminated all access to things like the git repositories ... so the person who wrote that code and expressed interest in continuing involvement (me) can not do so. So I don't know what to suggest in terms of getting patches merged upstream in a timely manner at this point. If this is not able to resolved by the gatekeeper, Kolab Systems, in a satisfactory manner in a reasonable amount of time, I will fork the repositories on github and continue maintenance / development of them there. -- Aaron Seigo _______________________________________________ devel mailing list [email protected] https://lists.kolab.org/mailman/listinfo/devel
extract_done_correctly.diff
(text/x-diff, 2.7 KB)
diff --git a/rebar.config b/rebar.config
index e8bac2a..ba0ba12 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,7 +1,7 @@
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
-{erl_opts, [warnings_as_errors, {parse_transform, lager_transform}]}.
+{erl_opts, [{parse_transform, lager_transform}]}.
{deps, [ lager ]}.
{ erl_first_files, ["src/eimap_command.erl"] }.
diff --git a/src/eimap_utils.erl b/src/eimap_utils.erl
index 84b5947..b41ef2f 100644
--- a/src/eimap_utils.erl
+++ b/src/eimap_utils.erl
@@ -156,14 +156,20 @@ remove_tag_from_response(Buffer, Tag, trust) ->
%% Private
split_command(<<>>) -> { <<>>, <<>>, <<>> };
split_command(Buffer) ->
- End = eol_found(Buffer, binary:match(Buffer, <<"\r\n">>)),
+ {Terminated, End} = eol_found(Buffer, binary:match(Buffer, <<"\r\n">>)),
{ Tag, CommandStart } = searched_in_buffer(Buffer, 0, End, binary:match(Buffer, <<" ">>, [ { scope, { 0, End } } ])),
- { Command, DataStart } = searched_in_buffer(Buffer, CommandStart, End, binary:match(Buffer, <<" ">>, [ { scope, { CommandStart, End - CommandStart } } ])),
- Data = binary:part(Buffer, DataStart, End - (DataStart)),
- { Tag, Command, Data }.
+ case Terminated of
+ true when End == CommandStart ->
+ %% when we have a newline, and the tag takes the entire line, the "tag" is actually the command
+ {<<>>, Tag, <<>>};
+ _ ->
+ { Command, DataStart } = searched_in_buffer(Buffer, CommandStart, End, binary:match(Buffer, <<" ">>, [ { scope, { CommandStart, End - CommandStart } } ])),
+ Data = binary:part(Buffer, DataStart, End - (DataStart)),
+ { Tag, Command, Data }
+ end.
-eol_found(Buffer, nomatch) -> size(Buffer);
-eol_found(_Buffer, { MatchStart, _MatchLength }) -> MatchStart.
+eol_found(Buffer, nomatch) -> {false, size(Buffer)};
+eol_found(_Buffer, { MatchStart, _MatchLength }) -> {true, MatchStart}.
searched_in_buffer(Buffer, Start, End, nomatch) -> { binary:part(Buffer, Start, End - Start), End };
searched_in_buffer(Buffer, Start, _End, { MatchStart, MatchLength } ) -> { binary:part(Buffer, Start, MatchStart - Start), MatchStart + MatchLength }.
diff --git a/test/eimap_utils_tests.erl b/test/eimap_utils_tests.erl
index dd111d4..838cf57 100644
--- a/test/eimap_utils_tests.erl
+++ b/test/eimap_utils_tests.erl
@@ -79,6 +79,7 @@ split_command_into_components_test_() ->
Data =
[
{ { <<>>, <<>>, <<>> }, <<>> },
+ { { <<>>, <<"DONE">>, <<>> }, <<"DONE\r\n">> },
{ { <<".">>, <<"LIST">>, <<"\"\" \"*\"">> }, <<". LIST \"\" \"*\"">> },
{ { <<"1">>, <<"STARTTLS">>, <<>> }, <<"1 STARTTLS">> },
{ { <<"1">>, <<"STARTTLS">>, <<>> }, <<"1 STARTTLS\r\n">> },