Пример #1
0
  private int processMsgs(RapidoidConnection conn) {
    int reqN = 0;

    while (reqN < MAX_PIPELINED && conn.input().hasRemaining() && processNext(conn)) {
      reqN++;
    }

    return reqN;
  }
Пример #2
0
  private boolean processNext(RapidoidConnection conn) {
    int pos = conn.input().position();
    int limit = conn.input().limit();

    try {
      protocol.process(conn);
      return true;
    } catch (IncompleteReadException e) {
      // input not ready, so recover
      conn.input().position(pos);
      conn.input().limit(limit);
      // FIXME recover output position
    } catch (ProtocolException e) {
      conn.write(U.or(e.getMessage(), "Protocol error!"));
      conn.error();
      conn.close(true);
    } catch (Throwable e) {
      U.error("Failed to process message!", e);
      conn.close(true);
    }

    return false;
  }