ReceivePack: enable capabilities immediately on first line

Instead of deferring until after command parsing, enable the
capabilities after the first pkt-line has been read from the client.
This allows the server to setup the side-band-64k channel immediately.

Change-Id: I141b7fc92e983a41d3a58da8e1464a6917422b6c
This commit is contained in:
Shawn Pearce 2016-07-05 12:37:26 -07:00
parent 60ca93798c
commit 306932c701
2 changed files with 5 additions and 5 deletions

View File

@ -1077,7 +1077,7 @@ public void sendAdvertisedRefs(final RefAdvertiser adv)
*/ */
protected void recvCommands() throws IOException { protected void recvCommands() throws IOException {
PushCertificateParser certParser = getPushCertificateParser(); PushCertificateParser certParser = getPushCertificateParser();
FirstLine firstLine = null; boolean firstPkt = true;
try { try {
for (;;) { for (;;) {
String line; String line;
@ -1097,10 +1097,12 @@ protected void recvCommands() throws IOException {
continue; continue;
} }
if (firstLine == null) { if (firstPkt) {
firstLine = new FirstLine(line); firstPkt = false;
FirstLine firstLine = new FirstLine(line);
enabledCapabilities = firstLine.getCapabilities(); enabledCapabilities = firstLine.getCapabilities();
line = firstLine.getLine(); line = firstLine.getLine();
enableCapabilities();
if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) { if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) {
certParser.receiveHeader(pckIn, !isBiDirectionalPipe()); certParser.receiveHeader(pckIn, !isBiDirectionalPipe());

View File

@ -184,8 +184,6 @@ private void service() throws IOException {
return; return;
recvCommands(); recvCommands();
if (hasCommands()) { if (hasCommands()) {
enableCapabilities();
Throwable unpackError = null; Throwable unpackError = null;
if (needPack()) { if (needPack()) {
try { try {