Giter Site home page Giter Site logo

ssdb-erlang's People

Contributors

kqqsysu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ssdb-erlang's Issues

parse receiving data exception

ssdb_conn.erl
parse_recv fun,when step =:= ?SSDB_STEP_DATA
the last message can match <<BlockData:Size/binary-unit:8, $\n:8, $\n:8, Res/binary>> or <<BlockData:Size/binary-unit:8, $\n:8, Res/binary>>
If the match <<BlockData:Size/binary-unit:8, $\n:8, Res/binary>>,step state = ?SSDB_STEP_SIZE,but it was the last message.
solution:
parse_recv(#ssdb_conn{step = ?SSDB_STEP_SIZE, data = Data} = State, InData) ->
NewData = <<Data/binary, InData/binary>>,
case binary:split(NewData, <<"\n">>) of
[<<>>, <<>>] -> %% repair
Reply = State#ssdb_conn.reply,
State#ssdb_conn{step = ?SSDB_STEP_FINISH, size = 0, data = <<>>, reply = lists:reverse(Reply)};
[BinSize, BlockData] ->
Size = erlang:binary_to_integer(BinSize),
NewState = State#ssdb_conn{data = BlockData, size = Size, step = ?SSDB_STEP_DATA},
parse_recv(NewState, <<>>); %% parse data
_ ->
%% wait for get size
State#ssdb_conn{data = NewData}
end;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.